Inheritance: implements OptionInterface
コード例 #1
0
 /**
  * Set option boolean value
  *
  * @param boolean $value
  * @throws \InvalidArgumentException
  */
 public function setValue($value)
 {
     if (!is_bool($value)) {
         throw new InvalidArgumentException('Boolean required');
     }
     parent::setValue($value);
 }
コード例 #2
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;
 }
コード例 #3
0
 /**
  * Set option integer value.
  *
  * @param int $value
  *
  * @throws \InvalidArgumentException
  */
 public function setValue($value)
 {
     if (!is_integer($value)) {
         throw new InvalidArgumentException('Integer required');
     }
     if ($this->minRange > $value || $this->maxRange < $value) {
         throw new InvalidArgumentException('Invalid Value');
     }
     parent::setValue($value);
 }
コード例 #4
0
 /**
  * Set option string value.
  *
  * @param string $value
  *
  * @throws \InvalidArgumentException
  */
 public function setValue($value)
 {
     if (!is_string($value)) {
         throw new InvalidArgumentException('String required');
     }
     if ($this->minRange > strlen($value) || $this->maxRange < strlen($value)) {
         throw new InvalidArgumentException('Invalid Value');
     }
     parent::setValue($value);
 }
コード例 #5
0
 public function testCreateFromTypeNull()
 {
     $this->assertNull(Option::createFromType('fail'));
 }