elementor
/
vendor_prefixed
/
php-di
/
php-di
/
src
/
Definition
/
ObjectDefinition
/
PropertyInjection.php
PropertyInjection.php in Elementor Website Builder – more than just a page builder 3.27.4, at vendor_prefixed/php-di/php-di/src/Definition/ObjectDefinition/PropertyInjection.php
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace ElementorDeps\DI\Definition\ObjectDefinition; |
| 5 | |
| 6 | /** |
| 7 | * Describe an injection in a class property. |
| 8 | * |
| 9 | * @author Matthieu Napoli <matthieu@mnapoli.fr> |
| 10 | */ |
| 11 | class PropertyInjection |
| 12 | { |
| 13 | /** |
| 14 | * Property name. |
| 15 | * @var string |
| 16 | */ |
| 17 | private $propertyName; |
| 18 | /** |
| 19 | * Value that should be injected in the property. |
| 20 | * @var mixed |
| 21 | */ |
| 22 | private $value; |
| 23 | /** |
| 24 | * Use for injecting in properties of parent classes: the class name |
| 25 | * must be the name of the parent class because private properties |
| 26 | * can be attached to the parent classes, not the one we are resolving. |
| 27 | * @var string|null |
| 28 | */ |
| 29 | private $className; |
| 30 | /** |
| 31 | * @param string $propertyName Property name |
| 32 | * @param mixed $value Value that should be injected in the property |
| 33 | */ |
| 34 | public function __construct(string $propertyName, $value, string $className = null) |
| 35 | { |
| 36 | $this->propertyName = $propertyName; |
| 37 | $this->value = $value; |
| 38 | $this->className = $className; |
| 39 | } |
| 40 | public function getPropertyName() : string |
| 41 | { |
| 42 | return $this->propertyName; |
| 43 | } |
| 44 | /** |
| 45 | * @return mixed Value that should be injected in the property |
| 46 | */ |
| 47 | public function getValue() |
| 48 | { |
| 49 | return $this->value; |
| 50 | } |
| 51 | /** |
| 52 | * @return string|null |
| 53 | */ |
| 54 | public function getClassName() |
| 55 | { |
| 56 | return $this->className; |
| 57 | } |
| 58 | public function replaceNestedDefinition(callable $replacer) |
| 59 | { |
| 60 | $this->value = $replacer($this->value); |
| 61 | } |
| 62 | } |
| 63 |