HEX
Server: Apache
System: Linux digivps 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC 2025 x86_64
User: www (1000)
PHP: 8.3.15
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/healthyton.com/wp-content/plugins/wordpress-popular-posts/src/Container/Container.php
<?php
/**
 * A Simple Dependency Injector Container (DIC).
 *
 * Largely based on Carl Alexander's Dependency Injection Container.
 * @link https://carlalexander.ca/dependency-injection-wordpress/
 */

namespace WordPressPopularPosts\Container;

class Container implements \ArrayAccess
{
    /**
     * Values stored inside the container.
     *
     * @var array
     */
    private $values;

    /**
     * Constructor.
     *
     * @param array $values
     */
    public function __construct(array $values = [])
    {
        $this->values = $values;
    }

    /**
     * Configure the container using the given container configuration objects.
     *
     * @param array $configurations
     */
    public function configure(array $configurations)
    {
        foreach ($configurations as $configuration) {
            if ( $configuration instanceof ContainerConfigurationInterface ) {
                $configuration->modify($this);
            }
        }
    }

    /**
     * Checks if there's a value in the container for the given key.
     *
     * @param mixed $key
     *
     * @return bool
     */
    public function offsetExists($key) : bool /** @TODO: starting PHP 8.0 $key can be declared as mixed $key, see https://www.php.net/manual/en/language.types.declarations.php */
    {
        return array_key_exists($key, $this->values);
    }

    /**
     * Sets a value inside of the container.
     *
     * @param mixed $key
     * @param mixed $value
     */
    public function offsetSet($key, $value) : void /** @TODO: starting PHP 8.0 $key and $value can be declared as mixed $key, mixed $value */
    {
        $this->values[$key] = $value;
    }

    /**
     * Unset the value in the container for the given key.
     *
     * @param mixed $key
     */
    public function offsetUnset($key) : void /** @TODO: starting PHP 8.0 $key can be declared as mixed $key */
    {
        unset($this->values[$key]);
    }

    /**
     * Get a value from the container.
     *
     * @param mixed $key
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($key) /** @TODO: starting PHP 8.0 $key can be declared as mixed $key */
    {
        if ( ! $this->offsetExists($key) ) {
            throw new \InvalidArgumentException(sprintf('Container doesn\'t have a value stored for the "%s" key.', $key));
        }
        return $this->values[$key] instanceof \Closure ? $this->values[$key]($this) : $this->values[$key];
    }

    /**
     * Creates a closure used for creating a service using the given callable.
     *
     * @param \Closure $closure
     *
     * @return \Closure
     */
    public function service(\Closure $closure)
    {
        return function(Container $container) use ($closure) {
            static $object;

            if ( null === $object ) {
                $object = $closure($container);
            }

            return $object;
        };
    }
}