Hackzilla\PasswordGenerator\Model\Option\Option::createFromType PHP Method

createFromType() public static method

public static createFromType ( $type, array $settings = [] )
$settings array
    public static function createFromType($type, array $settings = array())
    {
        switch ($type) {
            case self::TYPE_STRING:
                return new StringOption($settings);
            case self::TYPE_INTEGER:
                return new IntegerOption($settings);
            case self::TYPE_BOOLEAN:
                return new BooleanOption($settings);
        }
        return;
    }

Usage Example

コード例 #1
0
 /**
  * Set password generator option.
  *
  * @param string $option
  * @param array  $optionSettings
  *
  * @return $this
  * @throws InvalidOptionTypeException
  */
 public function setOption($option, $optionSettings)
 {
     $type = isset($optionSettings['type']) ? $optionSettings['type'] : '';
     $this->options[$option] = Option::createFromType($type, $optionSettings);
     if ($this->options[$option] === null) {
         throw new InvalidOptionTypeException('Invalid Option Type');
     }
     return $this;
 }
All Usage Examples Of Hackzilla\PasswordGenerator\Model\Option\Option::createFromType