parseInteger() public static method

public static parseInteger ( $value, $nullable = true )
Exemplo n.º 1
0
 /**
  * @dataProvider getInvalidParseIntegerTests
  * @expectedException \Webmozart\Console\Api\Args\Format\InvalidValueException
  */
 public function testParseIntegerFailsIfInvalid($input, $nullable = true)
 {
     StringUtil::parseInteger($input, $nullable);
 }
Exemplo n.º 2
0
 /**
  * Parses an argument value.
  *
  * Pass one of the flags {@link STRING}, {@link BOOLEAN}, {@link INTEGER}
  * and {@link FLOAT} to the constructor to configure the result of this
  * method. You can optionally combine the flags with {@link NULLABLE} to
  * support the conversion of "null" to `null`.
  *
  * @param mixed $value The value to parse.
  *
  * @return mixed The parsed value.
  *
  * @throws InvalidValueException
  */
 public function parseValue($value)
 {
     $nullable = $this->flags & self::NULLABLE;
     if ($this->flags & self::BOOLEAN) {
         return StringUtil::parseBoolean($value, $nullable);
     }
     if ($this->flags & self::INTEGER) {
         return StringUtil::parseInteger($value, $nullable);
     }
     if ($this->flags & self::FLOAT) {
         return StringUtil::parseFloat($value, $nullable);
     }
     return StringUtil::parseString($value, $nullable);
 }