# depicter/1.2.0/vendor/htmlburger/wpemerge/src/Application/HasContainerTrait.php

Depicter — Popup &amp; Slider Builder, version 1.2.0. 60 lines.

- Page: https://pluginprobe.com/plugins/depicter/1.2.0/code/vendor/htmlburger/wpemerge/src/Application/HasContainerTrait.php
- Raw: https://pluginprobe.com/plugins/depicter/1.2.0/raw/vendor/htmlburger/wpemerge/src/Application/HasContainerTrait.php
- Modified: 2022-06-01T06:26:20+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/depicter/1.2.0/code/vendor/htmlburger/wpemerge/src/Application/HasContainerTrait.php#L10-L20`.

```php
<?php
/**
 * @package   WPEmerge
 * @author    Atanas Angelov <hi@atanas.dev>
 * @copyright 2017-2019 Atanas Angelov
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
 * @link      https://wpemerge.com/
 */

namespace WPEmerge\Application;

use Pimple\Container;

/**
 * Holds an IoC container.
 */
trait HasContainerTrait {
	/**
	 * IoC container.
	 *
	 * @var Container
	 */
	protected $container = null;

	/**
	 * Get the IoC container instance.
	 *
	 * @codeCoverageIgnore
	 * @return Container
	 */
	public function container() {
		return $this->container;
	}

	/**
	 * Set the IoC container instance.
	 *
	 * @codeCoverageIgnore
	 * @param  Container $container
	 * @return void
	 */
	public function setContainer( $container ) {
		$this->container = $container;
	}

	/**
	 * Resolve a dependency from the IoC container.
	 *
	 * @param  string     $key
	 * @return mixed|null
	 */
	public function resolve( $key ) {
		if ( ! isset( $this->container()[ $key ] ) ) {
			return null;
		}

		return $this->container()[ $key ];
	}
}

```
