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