1 | <?php |
||
15 | class ReflectionObject |
||
16 | { |
||
17 | private $object; |
||
18 | private $properties; |
||
19 | private $injectionStrategies; |
||
20 | private $extractionStrategies; |
||
21 | |||
22 | 13 | public function __construct( |
|
39 | |||
40 | /** |
||
41 | * Add a property that will be injected |
||
42 | * |
||
43 | * @param string $name |
||
44 | * @param mixed $value |
||
45 | * |
||
46 | * @return self |
||
47 | */ |
||
48 | 4 | public function withProperty(string $name, $value) |
|
57 | |||
58 | /** |
||
59 | * Add a set of properties that need to be injected |
||
60 | * |
||
61 | * @param array $properties |
||
62 | * |
||
63 | * @return self |
||
64 | */ |
||
65 | 1 | public function withProperties(array $properties): self |
|
74 | |||
75 | /** |
||
76 | * Return the collection of properties that will be injected in the object |
||
77 | * |
||
78 | * @return CollectionInterface |
||
79 | */ |
||
80 | 2 | public function getProperties(): CollectionInterface |
|
84 | |||
85 | /** |
||
86 | * Return the list of injection strategies used |
||
87 | * |
||
88 | * @return InjectionStrategies |
||
89 | */ |
||
90 | 1 | public function getInjectionStrategies(): InjectionStrategies |
|
94 | |||
95 | /** |
||
96 | * Return the list of extraction strategies used |
||
97 | * |
||
98 | * @return ExtractionStrategies |
||
99 | */ |
||
100 | 1 | public function getExtractionStrategies(): ExtractionStrategies |
|
104 | |||
105 | /** |
||
106 | * Return the object with the list of properties set on it |
||
107 | * |
||
108 | * @return object |
||
109 | */ |
||
110 | 7 | public function buildObject() |
|
118 | |||
119 | /** |
||
120 | * Extract the given list of properties |
||
121 | * |
||
122 | * @param array $properties |
||
123 | * |
||
124 | * @return CollectionInterface |
||
125 | */ |
||
126 | 2 | public function extract(array $properties): CollectionInterface |
|
136 | |||
137 | /** |
||
138 | * Inject the given key/value pair into the object |
||
139 | * |
||
140 | * @param string $key |
||
141 | * @param mixed $value |
||
142 | * |
||
143 | * @return void |
||
144 | */ |
||
145 | 5 | private function inject(string $key, $value) |
|
152 | |||
153 | /** |
||
154 | * Extract the given property out of the object |
||
155 | * |
||
156 | * @param string $property |
||
157 | * |
||
158 | * @return mixed |
||
159 | */ |
||
160 | 2 | private function extractProperty(string $property) |
|
167 | } |
||
168 |