1 | <?php |
||
13 | class ClassMetadata |
||
14 | { |
||
15 | const LOGIN_PROPERTY = 1; |
||
16 | const PASSWORD_PROPERTY = 2; |
||
17 | const API_KEY_PROPERTY = 3; |
||
18 | const LAST_ACTION_PROPERTY = 4; |
||
19 | |||
20 | /** |
||
21 | * @var int[] |
||
22 | */ |
||
23 | private static $necessaryProperties = array( |
||
24 | self::LOGIN_PROPERTY => 'login', |
||
25 | self::PASSWORD_PROPERTY => 'password', |
||
26 | self::API_KEY_PROPERTY => 'apiKey', |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * @var ReflectionProperty[] |
||
31 | */ |
||
32 | private $properties = array(); |
||
33 | |||
34 | /** |
||
35 | * @var string[] |
||
36 | */ |
||
37 | private $lazyPropertyNameCache = array(); |
||
38 | |||
39 | /** |
||
40 | * @var string[] |
||
41 | */ |
||
42 | private $lazyValueCache = array(); |
||
43 | |||
44 | /** |
||
45 | * Constructor. |
||
46 | * |
||
47 | * @param ReflectionProperty[] $properties |
||
48 | * |
||
49 | * @throws \InvalidArgumentException If one necessary property is missing |
||
50 | */ |
||
51 | 12 | public function __construct(array $properties) |
|
64 | |||
65 | /** |
||
66 | * Gets the value of the given property. |
||
67 | * |
||
68 | * @param object $user |
||
69 | * @param int $property |
||
70 | * @param bool $strict |
||
71 | * |
||
72 | * @return mixed |
||
73 | */ |
||
74 | 5 | public function getPropertyValue($user, $property = self::LOGIN_PROPERTY, $strict = false) |
|
91 | |||
92 | /** |
||
93 | * Gets the name of a specific property by its metadata constant. |
||
94 | * |
||
95 | * @param int $property |
||
96 | * @param bool $strict |
||
97 | * |
||
98 | * @return null|string |
||
99 | */ |
||
100 | 9 | public function getPropertyName($property = self::LOGIN_PROPERTY, $strict = false) |
|
110 | |||
111 | /** |
||
112 | * Modifies a property and clears the cache. |
||
113 | * |
||
114 | * @param object $user |
||
115 | * @param mixed $newValue |
||
116 | * @param int $property |
||
117 | */ |
||
118 | 6 | public function modifyProperty($user, $newValue, $property = self::LOGIN_PROPERTY) |
|
128 | |||
129 | /** |
||
130 | * Validates a property. |
||
131 | * |
||
132 | * @param int $property |
||
133 | * @param bool $strict |
||
134 | * |
||
135 | * @return bool |
||
136 | */ |
||
137 | 10 | private function checkProperty($property = self::LOGIN_PROPERTY, $strict = false) |
|
152 | } |
||
153 |