src/sms/Sms.php
public function strategy($strategy = null)
    {
        if (is_null($strategy)) {
            $strategy = $this->defaultStrategy ?: OrderStrategy::class;
        }

        if (!class_exists($strategy)) {
            $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy);
        }

        if (!class_exists($strategy)) {
            throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\"");
        }

        if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) {
            $this->strategies[$strategy] = new $strategy($this);
        }

        return $this->strategies[$strategy];
    }
public function strategy($strategy = null)
    {
        if (is_null($strategy)) {
            $strategy = $this->defaultStrategy ?: OrderStrategy::class;
        }

        if (!class_exists($strategy)) {
            $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy);
        }

        if (!class_exists($strategy)) {
            throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\"");
        }

        if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) {
            $this->strategies[$strategy] = new $strategy($this);
        }

        return $this->strategies[$strategy];
    }
public function strategy ( $ strategy = null ) { if ( is_null ( $ strategy ) ) { $ strategy = $ this -> defaultStrategy ? : OrderStrategy :: class ; } if ( ! class_exists ( $ strategy ) ) { $ strategy = __NAMESPACE__ . '\strategies\\' . ucfirst ( $ strategy ) ; } if ( ! class_exists ( $ strategy ) ) { throw new InvalidArgumentException ( "Unsupported strategy \"{$strategy}\"" ) ; } if ( empty ( $ this -> strategies [ $ strategy ] ) || ! ( $ this -> strategies [ $ strategy ] instanceof StrategyInterface ) ) { $ this -> strategies [ $ strategy ] = new $ strategy ( $ this ) ; } return $ this -> strategies [ $ strategy ] ; }
Get a strategy instance.

@param string|null $strategy
@return StrategyInterface
@throws InvalidArgumentException
Get a strategy instance .