Server IP : 213.176.29.180  /  Your IP : 3.135.218.67
Web Server : Apache
System : Linux 213.176.29.180.hostiran.name 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
User : webtaragh ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/webtaragh/public_html/whmcs/vendor/mindplay/middleman/src/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/webtaragh/public_html/whmcs/vendor/mindplay/middleman/src/ContainerResolver.php
<?php

namespace mindplay\middleman;

use Interop\Container\ContainerInterface;
use RuntimeException;

/**
 * Optionally, pass this as `$resolver` to {@see Dispatcher::__construct()} to provide
 * integration with a dependency injection container - for example:
 *
 *     $dispatcher = new Dispatcher(
 *         [
 *             RouterMiddleware::class,
 *             ErrorMiddleware::class,
 *         ],
 *         new InteropResolver($container)
 *     );
 *
 * Note that this resolver will ignore any middleware component that is not a string - so you
 * can mix component names with regular middleware closures, callable objects, and so on.
 *
 * You can use class-names or other component names, depending on what your container supports.
 *
 * @link https://github.com/container-interop/container-interop
 */
class ContainerResolver
{
    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function __invoke($name)
    {
        if (! is_string($name)) {
            return $name; // nothing to resolve (may be a closure or other callable middleware object)
        }

        if ($this->container->has($name)) {
            return $this->container->get($name);
        }

        throw new RuntimeException("unable to resolve middleware component name: {$name}");
    }
}