# cookiebot/3.11.3/addons/inc/Dependencies/DI/Annotation/Injectable.php

Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA &amp; Google Consent Mode, version 3.11.3. 75 lines.

- Page: https://pluginprobe.com/plugins/cookiebot/3.11.3/code/addons/inc/Dependencies/DI/Annotation/Injectable.php
- Raw: https://pluginprobe.com/plugins/cookiebot/3.11.3/raw/addons/inc/Dependencies/DI/Annotation/Injectable.php
- Modified: 2021-03-23T11:49:48+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/cookiebot/3.11.3/code/addons/inc/Dependencies/DI/Annotation/Injectable.php#L10-L20`.

```php
<?php
/**
 * PHP-DI
 *
 * @link      http://php-di.org/
 * @copyright Matthieu Napoli (http://mnapoli.fr/)
 * @license   http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
 */

namespace Cybot\Dependencies\DI\Annotation;

use Cybot\Dependencies\DI\Scope;
use UnexpectedValueException;

/**
 * "Injectable" annotation
 *
 * Marks a class as injectable
 *
 * @Annotation
 * @Target("CLASS")
 *
 * @author Domenic Muskulus <domenic@muskulus.eu>
 * @author Matthieu Napoli <matthieu@mnapoli.fr>
 */
final class Injectable
{
    /**
     * The scope of an class: prototype, singleton
     * @var string|null
     */
    private $scope;

    /**
     * Should the object be lazy-loaded
     * @var boolean|null
     */
    private $lazy;

    /**
     * @param array $values
     */
    public function __construct(array $values)
    {
        if (isset($values['scope'])) {
            if ($values['scope'] === 'prototype') {
                $this->scope = Scope::PROTOTYPE;
            } elseif ($values['scope'] === 'singleton') {
                $this->scope = Scope::SINGLETON;
            } else {
                throw new UnexpectedValueException(sprintf("Value '%s' is not a valid scope", $values['scope']));
            }
        }
        if (isset($values['lazy'])) {
            $this->lazy = (boolean) $values['lazy'];
        }
    }

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

    /**
     * @return boolean|null
     */
    public function isLazy()
    {
        return $this->lazy;
    }
}

```
