@@ 23-42 (lines=20) @@ | ||
20 | private $injectionStrategy; |
|
21 | private $instanciator; |
|
22 | ||
23 | public function __construct( |
|
24 | string $class, |
|
25 | MapInterface $properties = null, |
|
26 | InjectionStrategyInterface $injectionStrategy = null, |
|
27 | InstanciatorInterface $instanciator = null |
|
28 | ) { |
|
29 | $properties = $properties ?? new Map('string', 'mixed'); |
|
30 | ||
31 | if ( |
|
32 | (string) $properties->keyType() !== 'string' || |
|
33 | (string) $properties->valueType() !== 'mixed' |
|
34 | ) { |
|
35 | throw new InvalidArgumentException; |
|
36 | } |
|
37 | ||
38 | $this->class = $class; |
|
39 | $this->properties = $properties; |
|
40 | $this->injectionStrategy = $injectionStrategy ?? InjectionStrategies::default(); |
|
41 | $this->instanciator = $instanciator ?? new ReflectionInstanciator; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * Add a property to be injected in the new object |
@@ 25-45 (lines=21) @@ | ||
22 | private $injectionStrategy; |
|
23 | private $extractionStrategy; |
|
24 | ||
25 | public function __construct( |
|
26 | $object, |
|
27 | MapInterface $properties = null, |
|
28 | InjectionStrategyInterface $injectionStrategy = null, |
|
29 | ExtractionStrategyInterface $extractionStrategy = null |
|
30 | ) { |
|
31 | $properties = $properties ?? new Map('string', 'mixed'); |
|
32 | ||
33 | if ( |
|
34 | !is_object($object) || |
|
35 | (string) $properties->keyType() !== 'string' || |
|
36 | (string) $properties->valueType() !== 'mixed' |
|
37 | ) { |
|
38 | throw new InvalidArgumentException; |
|
39 | } |
|
40 | ||
41 | $this->object = $object; |
|
42 | $this->properties = $properties; |
|
43 | $this->injectionStrategy = $injectionStrategy ?? InjectionStrategies::default(); |
|
44 | $this->extractionStrategy = $extractionStrategy ?? ExtractionStrategies::default(); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Add a property that will be injected |