1 | <?php |
||
16 | class MatchedPreference implements MatchedPreferenceInterface |
||
17 | { |
||
18 | /** |
||
19 | * Which HTTP field the match relates to. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $fromField; |
||
24 | |||
25 | /** |
||
26 | * The preference from the client. |
||
27 | * |
||
28 | * @var PreferenceInterface |
||
29 | */ |
||
30 | private $clientPref; |
||
31 | |||
32 | /** |
||
33 | * The preference from the server. |
||
34 | * |
||
35 | * @var PreferenceInterface |
||
36 | */ |
||
37 | private $serverPref; |
||
38 | |||
39 | |||
40 | /** |
||
41 | * Constructor. |
||
42 | * |
||
43 | * @param string $fromField |
||
44 | * @param PreferenceInterface $serverPref |
||
45 | * @param PreferenceInterface $clientPref |
||
46 | */ |
||
47 | 82 | public function __construct($fromField, PreferenceInterface $clientPref, PreferenceInterface $serverPref) |
|
53 | |||
54 | /** |
||
55 | * @inheritDoc |
||
56 | */ |
||
57 | 77 | public function getClientPreference() |
|
61 | |||
62 | /** |
||
63 | * @inheritDoc |
||
64 | */ |
||
65 | 77 | public function getServerPreference() |
|
69 | |||
70 | /** |
||
71 | * Get the shared variant for this pair. |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 71 | public function getVariant() |
|
91 | |||
92 | /** |
||
93 | * Returns true if the match was by partial language wildcard. |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | 71 | private function isLanguageWildcard() |
|
102 | |||
103 | /** |
||
104 | * Returns true if the client contained a wildcard or was absent. |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | 71 | private function clientWildcardOrAbsent() |
|
112 | |||
113 | /** |
||
114 | * Returns the product of the server & client quality factors. |
||
115 | * |
||
116 | * @return float |
||
117 | */ |
||
118 | 77 | public function getQualityFactor() |
|
122 | |||
123 | /** |
||
124 | * Returns the combined precedence. |
||
125 | * |
||
126 | * @return int |
||
127 | */ |
||
128 | 29 | public function getPrecedence() |
|
132 | |||
133 | /** |
||
134 | * Create string representation of the preference. |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | 2 | public function __toString() |
|
142 | } |
||
143 |