1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<?php /** * * This file is part of Aura for PHP. * * @license http://opensource.org/licenses/bsd-license.php BSD * */ namespace Aura\Accept\Media;
use Aura\Accept\AbstractValue;
/** * * Represents an acceptable media type value. * * @package Aura.Accept * */ class MediaValue extends AbstractValue { /** * * The media type. * * @var string * */ protected $type = '*';
/** * * The media subtype. * * @var string * */ protected $subtype = '*';
/** * * Finishes construction of the value object. * * @return null * */ protected function init() { $values = explode('/', $this->value); $this->type = $values[0]; $this->subtype = isset($values[1]) ? $values[1] : '*'; }
/** * * Returns the media type. * * @return string * */ public function getType() { return $this->type; }
/** * * Returns the media subtype. * * @return string * */ public function getSubtype() { return $this->subtype; }
/** * * Is the acceptable value a wildcard? * * @return bool * */ public function isWildcard() { return $this->value == '*/*'; }
/** * * Checks if an available media type value matches this acceptable value. * * @param Media $avail An available media type value. * * @return True on a match, false if not. * */ public function match(MediaValue $avail) { if ($avail->getValue() == '*/*') { return true; }
// is it a full match? if (strtolower($this->value) == strtolower($avail->getValue())) { return $this->matchParameters($avail); }
// is it a type match? return $this->subtype == '*' && strtolower($this->type) == strtolower($avail->getType()) && $this->matchParameters($avail); } }
|