vendor/codeages/biz-framework/src/Context/CallbackResolver.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

/*
 * 此文件来自 Silex 项目(https://github.com/silexphp/Silex).
 *
 * 版权信息请看 LICENSE.SILEX
 */

namespace Codeages\Biz\Framework\Context;

use Pimple\Container;

class CallbackResolver
{
    const SERVICE_PATTERN = "/[A-Za-z0-9\._\-]+:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/";

    private $app;

    public function __construct(Container $app)
    {
        $this->app = $app;
    }

    /**
     * Returns true if the string is a valid service method representation.
     *
     * @param string $name
     *
     * @return bool
     */
    public function isValid($name)
    {
        return is_string($name) && (preg_match(static::SERVICE_PATTERN, $name) || isset($this->app[$name]));
    }

    /**
     * Returns a callable given its string representation.
     *
     * @param string $name
     *
     * @return callable
     *
     * @throws \InvalidArgumentException in case the method does not exist
     */
    public function convertCallback($name)
    {
        if (preg_match(static::SERVICE_PATTERN, $name)) {
            list($service, $method) = explode(':', $name, 2);
            $callback = array($this->app[$service], $method);
        } else {
            $service = $name;
            $callback = $this->app[$name];
        }

        if (!is_callable($callback)) {
            throw new \InvalidArgumentException(sprintf('Service "%s" is not callable.', $service));
        }

        return $callback;
    }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。