Пример #1
0
 public function __construct(string $class, CollectionInterface $properties = null, TypedCollectionInterface $injectionStrategies = null, InstanciatorInterface $instanciator = null)
 {
     $injectionStrategies = $injectionStrategies ?? InjectionStrategies::defaults();
     if ($injectionStrategies->getType() !== InjectionStrategyInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->class = $class;
     $this->properties = $properties ?? new Collection([]);
     $this->injectionStrategies = $injectionStrategies;
     $this->instanciator = $instanciator ?? new ReflectionInstanciator();
 }
Пример #2
0
 public function __construct($object, CollectionInterface $properties = null, TypedCollectionInterface $injectionStrategies = null, TypedCollectionInterface $extractionStrategies = null)
 {
     if (!is_object($object)) {
         throw new InvalidArgumentException();
     }
     $injectionStrategies = $injectionStrategies ?? InjectionStrategies::defaults();
     $extractionStrategies = $extractionStrategies ?? ExtractionStrategies::defaults();
     if ($injectionStrategies->getType() !== InjectionStrategyInterface::class) {
         throw new InvalidArgumentException();
     }
     if ($extractionStrategies->getType() !== ExtractionStrategyInterface::class) {
         throw new InvalidArgumentException();
     }
     $this->object = $object;
     $this->properties = $properties ?? new Collection([]);
     $this->injectionStrategies = $injectionStrategies;
     $this->extractionStrategies = $extractionStrategies;
 }