/var/www/hkosl.com/littleark/webadmin/libraies/aura/accept/src/AbstractValue.php


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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
 *
 * This file is part of Aura for PHP.
 *
 * @license http://opensource.org/licenses/bsd-license.php BSD
 *
 */
namespace Aura\Accept;

/**
 *
 * Represents an acceptable value.
 *
 * @package Aura.Accept
 *
 */
abstract class AbstractValue
{
    
/**
     *
     * The acceptable value, not including any parameters.
     *
     * @var string
     *
     */
    
protected $value;

    
/**
     *
     * The quality parameter.
     *
     * @var float
     *
     */
    
protected $quality 1.0;

    
/**
     *
     * Parameters additional to the acceptable value.
     *
     * @var array
     *
     */
    
protected $parameters = array();

    
/**
     *
     * Constructor.
     *
     * @param string $value The acceptable value, not including any parameters.
     *
     * @param float $quality The quality parameter.
     *
     * @param array $parameters Other parameters additional to the value.
     *
     */
    
public function __construct(
        
$value,
        
$quality,
        array 
$parameters
    
) {
        
$this->value $value;
        
$this->quality $quality;
        
$this->parameters $parameters;
        
$this->init();
    }

    
/**
     *
     * Finishes construction of the value object.
     *
     * @return null
     *
     */
    
protected function init()
    {
    }

    
/**
     *
     * Match against the parameters of an available value.
     *
     * @param AbstractValue $avail The available value.
     *
     * @return bool True on a match, false if not.
     *
     */
    
protected function matchParameters(AbstractValue $avail)
    {
        foreach (
$avail->getParameters() as $label => $value) {
            if (
$this->parameters[$label] != $value) {
                return 
false;
            }
        }
        return 
true;
    }

    
/**
     *
     * Is the acceptable value a wildcard?
     *
     * @return bool
     *
     */
    
public function isWildcard()
    {
        return 
$this->value == '*';
    }

    
/**
     *
     * Returns the acceptable value.
     *
     * @return string
     *
     */
    
public function getValue()
    {
        return 
$this->value;
    }

    
/**
     *
     * Returns the quality level.
     *
     * @return float
     *
     */
    
public function getQuality()
    {
        return (float) 
$this->quality;
    }

    
/**
     *
     * Returns the additional parameters.
     *
     * @return array
     *
     */
    
public function getParameters()
    {
        return 
$this->parameters;
    }
}