Webmozart\Console\Util\StringUtil::parseInteger PHP Method

parseInteger() public static method

public static parseInteger ( $value, $nullable = true )
    public static function parseInteger($value, $nullable = true)
    {
        if ($nullable && (null === $value || 'null' === $value)) {
            return null;
        }
        if (is_numeric($value) || is_bool($value)) {
            return (int) $value;
        }
        throw new InvalidValueException(sprintf('The value "%s" cannot be parsed as integer.', $value));
    }

Usage Example

Esempio n. 1
0
 /**
  * @dataProvider getInvalidParseIntegerTests
  * @expectedException \Webmozart\Console\Api\Args\Format\InvalidValueException
  */
 public function testParseIntegerFailsIfInvalid($input, $nullable = true)
 {
     StringUtil::parseInteger($input, $nullable);
 }
All Usage Examples Of Webmozart\Console\Util\StringUtil::parseInteger