# cookiebot/4.7.2/src/lib/Dependency_Container.php

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

- Page: https://pluginprobe.com/plugins/cookiebot/4.7.2/code/src/lib/Dependency_Container.php
- Raw: https://pluginprobe.com/plugins/cookiebot/4.7.2/raw/src/lib/Dependency_Container.php
- Modified: 2026-03-03T12:50:38+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/4.7.2/code/src/lib/Dependency_Container.php#L10-L20`.

```php
<?php

namespace cybot\cookiebot\lib;

use Exception;
use InvalidArgumentException;

class Dependency_Container {


	/**
	 * @var array
	 */
	private $dependencies;

	/**
	 * Dependency_Container constructor.
	 *
	 * @param array $dependencies
	 */
	public function __construct( array $dependencies = array() ) {
		$this->dependencies = $dependencies;
	}

	/**
	 * @param $key
	 * @param $dependency
	 *
	 * @throws Exception
	 */
	public function set( $key, $dependency ) {
		if ( isset( $this->dependencies[ $key ] ) ) {
			throw new InvalidArgumentException( 'Dependency key ' . esc_html( $key ) . ' already exists' );
		}
		$this->dependencies[ $key ] = $dependency;
	}

	/**
	 * @param $key
	 *
	 * @return mixed
	 * @throws Exception
	 */
	public function get( $key ) {
		if ( ! isset( $this->dependencies[ $key ] ) ) {
			throw new InvalidArgumentException( 'Dependency key ' . esc_html( $key ) . ' does not exist' );
		}

		return $this->dependencies[ $key ];
	}
}

```
