# betterdocs/3.8.1/includes/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php

BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ &amp; Chatbot, version 3.8.1. 71 lines.

- Page: https://pluginprobe.com/plugins/betterdocs/3.8.1/code/includes/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php
- Raw: https://pluginprobe.com/plugins/betterdocs/3.8.1/raw/includes/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php
- Modified: 2023-08-14T08:41:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterdocs/3.8.1/code/includes/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php#L10-L20`.

```php
<?php

declare(strict_types=1);

namespace WPDeveloper\BetterDocs\Dependencies\DI\Definition\ObjectDefinition;

/**
 * Describe an injection in a class property.
 *
 * @author Matthieu Napoli <matthieu@mnapoli.fr>
 */
class PropertyInjection
{
    /**
     * Property name.
     * @var string
     */
    private $propertyName;

    /**
     * Value that should be injected in the property.
     * @var mixed
     */
    private $value;

    /**
     * Use for injecting in properties of parent classes: the class name
     * must be the name of the parent class because private properties
     * can be attached to the parent classes, not the one we are resolving.
     * @var string|null
     */
    private $className;

    /**
     * @param string $propertyName Property name
     * @param mixed $value Value that should be injected in the property
     */
    public function __construct(string $propertyName, $value, string $className = null)
    {
        $this->propertyName = $propertyName;
        $this->value = $value;
        $this->className = $className;
    }

    public function getPropertyName() : string
    {
        return $this->propertyName;
    }

    /**
     * @return mixed Value that should be injected in the property
     */
    public function getValue()
    {
        return $this->value;
    }

    /**
     * @return string|null
     */
    public function getClassName()
    {
        return $this->className;
    }

    public function replaceNestedDefinition(callable $replacer)
    {
        $this->value = $replacer($this->value);
    }
}

```
