public function getBehavior($slug, $strategy = self::DEFAULT_STRATEGY)
    {
        $this->logger->debug('Swivel - Creating new behavior.', compact('slug'));
        if ($strategy === static::DEFAULT_STRATEGY) {
            $strategy = $slug;
            $slug = static::DEFAULT_SLUG;
        }

        if (!is_callable($strategy)) {
            if (is_string($strategy)) {
                $strategy = explode('::', $strategy);
            }
            if (!isset($strategy[0], $strategy[1]) || !method_exists($strategy[0], $strategy[1])) {
                throw new \LogicException('Invalid callable passed to Zumba\Swivel\Builder::getBehavior');
            }
            $closure = function () use ($strategy) {
                return call_user_func_array($strategy, func_get_args());
            };
            $strategy = $closure->bindTo(null, $strategy[0]);
        }
        $slug = empty($slug) ? $this->slug : $this->slug.Map::DELIMITER.$slug;

        return new Behavior($slug, $strategy, $this->logger);
    }
public function getBehavior($slug, $strategy = self::DEFAULT_STRATEGY)
    {
        $this->logger->debug('Swivel - Creating new behavior.', compact('slug'));
        if ($strategy === static::DEFAULT_STRATEGY) {
            $strategy = $slug;
            $slug = static::DEFAULT_SLUG;
        }

        if (!is_callable($strategy)) {
            if (is_string($strategy)) {
                $strategy = explode('::', $strategy);
            }
            if (!isset($strategy[0], $strategy[1]) || !method_exists($strategy[0], $strategy[1])) {
                throw new \LogicException('Invalid callable passed to Zumba\Swivel\Builder::getBehavior');
            }
            $closure = function () use ($strategy) {
                return call_user_func_array($strategy, func_get_args());
            };
            $strategy = $closure->bindTo(null, $strategy[0]);
        }
        $slug = empty($slug) ? $this->slug : $this->slug.Map::DELIMITER.$slug;

        return new Behavior($slug, $strategy, $this->logger);
    }
public function getBehavior ( $ slug , $ strategy = self :: DEFAULT_STRATEGY ) { $ this -> logger -> debug ( 'Swivel - Creating new behavior.' , compact ( 'slug' ) ) ; if ( $ strategy === static :: DEFAULT_STRATEGY ) { $ strategy = $ slug ; $ slug = static :: DEFAULT_SLUG ; } if ( ! is_callable ( $ strategy ) ) { if ( is_string ( $ strategy ) ) { $ strategy = explode ( '::' , $ strategy ) ; } if ( ! isset ( $ strategy [ 0 ] , $ strategy [ 1 ] ) || ! method_exists ( $ strategy [ 0 ] , $ strategy [ 1 ] ) ) { throw new \ LogicException ( 'Invalid callable passed to Zumba\Swivel\Builder::getBehavior' ) ; } $ closure = function ( ) use ( $ strategy ) { return call_user_func_array ( $ strategy , func_get_args ( ) ) ; } ; $ strategy = $ closure -> bindTo ( null , $ strategy [ 0 ] ) ; } $ slug = empty ( $ slug ) ? $ this -> slug : $ this -> slug . Map :: DELIMITER . $ slug ; return new Behavior ( $ slug , $ strategy , $ this -> logger ) ; }
Create and return a new Behavior.

The $strategy parameter must be a valid callable.

@param string   $slug
@param callable $strategy

@return \Zumba\Swivel\BehaviorInterface
Create and return a new Behavior .