parseFloat() public static méthode

public static parseFloat ( $value, $nullable = true )
Exemple #1
0
 /**
  * @dataProvider getInvalidParseFloatTests
  * @expectedException \Webmozart\Console\Api\Args\Format\InvalidValueException
  */
 public function testParseFloatFailsIfInvalid($input, $nullable = true)
 {
     StringUtil::parseFloat($input, $nullable);
 }
Exemple #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);
 }