/** * @dataProvider getParseStringTests */ public function testParseString($input, $output, $nullable = true) { $this->assertSame($output, StringUtil::parseString($input, $nullable)); }
/** * 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); }