1 | <?php |
||
21 | class ClassMetadata |
||
22 | { |
||
23 | const LOGIN_PROPERTY = 1; |
||
24 | const PASSWORD_PROPERTY = 2; |
||
25 | const API_KEY_PROPERTY = 3; |
||
26 | const LAST_ACTION_PROPERTY = 4; |
||
27 | |||
28 | /** |
||
29 | * @var int[] |
||
30 | */ |
||
31 | private static $necessaryProperties = array( |
||
32 | self::LOGIN_PROPERTY => 'login', |
||
33 | self::PASSWORD_PROPERTY => 'password', |
||
34 | self::API_KEY_PROPERTY => 'apiKey', |
||
35 | ); |
||
36 | |||
37 | /** |
||
38 | * @var ReflectionClass |
||
39 | */ |
||
40 | private $reflectionInstance; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private $className; |
||
46 | |||
47 | /** |
||
48 | * @var ReflectionProperty[] |
||
49 | */ |
||
50 | private $properties = array(); |
||
51 | |||
52 | /** |
||
53 | * @var string[] |
||
54 | */ |
||
55 | private $lazyPropertyNameCache = array(); |
||
56 | |||
57 | /** |
||
58 | * @var string[] |
||
59 | */ |
||
60 | private $lazyValueCache = array(); |
||
61 | |||
62 | /** |
||
63 | * Constructor. |
||
64 | * |
||
65 | * @param ReflectionClass $reflection |
||
66 | * @param string $className |
||
67 | * @param ReflectionProperty[] $properties |
||
68 | * |
||
69 | * @throws \InvalidArgumentException If one necessary property is missing |
||
70 | */ |
||
71 | 5 | public function __construct(ReflectionClass $reflection, $className, array $properties) |
|
86 | |||
87 | /** |
||
88 | * Gets the value of the given property. |
||
89 | * |
||
90 | * @param object $user |
||
91 | * @param int $property |
||
92 | * @param bool $strict |
||
93 | * |
||
94 | * @return mixed |
||
95 | */ |
||
96 | 2 | public function getPropertyValue($user, $property = self::LOGIN_PROPERTY, $strict = false) |
|
114 | |||
115 | /** |
||
116 | * Gets the name of a specific property by its metadata constant. |
||
117 | * |
||
118 | * @param int $property |
||
119 | * @param bool $strict |
||
120 | * |
||
121 | * @return null|string |
||
122 | */ |
||
123 | 4 | public function getPropertyName($property = self::LOGIN_PROPERTY, $strict = false) |
|
135 | |||
136 | /** |
||
137 | * Modifies a property and clears the cache. |
||
138 | * |
||
139 | * @param object $user |
||
140 | * @param mixed $newValue |
||
141 | * @param int $property |
||
142 | */ |
||
143 | 2 | public function modifyProperty($user, $newValue, $property = self::LOGIN_PROPERTY) |
|
153 | |||
154 | /** |
||
155 | * Validates a property. |
||
156 | * |
||
157 | * @param int $property |
||
158 | * @param bool $strict |
||
159 | * |
||
160 | * @return bool |
||
161 | */ |
||
162 | 4 | private function checkProperty($property = self::LOGIN_PROPERTY, $strict = false) |
|
177 | } |
||
178 |