Pheasant\Options::coerce PHP Method

coerce() public static method

Convert either a null, a string or an array into an Option
public static coerce ( $from )
    public static function coerce($from)
    {
        if (is_array($from) || is_null($from)) {
            return new self((array) $from);
        } elseif (is_string($from)) {
            return self::fromString($from);
        } elseif ($from instanceof Options) {
            return $from;
        } else {
            throw new \InvalidArgumentException("Unable to coerce provided type");
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Constructor
  */
 public function __construct($options = null)
 {
     $this->_options = Options::coerce($options);
 }