public static function convert($value, $options = self::VAR_STRING) { $options = (int) $options; if ($options & self::VAR_STRING && !empty($value)) { return trim(Filter::stripQuotes($value)); } if ($options & self::VAR_FLOAT) { return Filter::float($value, 12); } if ($options & self::VAR_INT) { return Filter::int($value); } if ($options & self::VAR_BOOL || $options & self::VAR_NULL) { if (null === $value || 'null' === strtolower(trim($value))) { return null; } return Filter::bool($value); } return (string) $value; }
/** * @dataProvider dataProvider * @param mixed $value * @param int $options * @param mixed $expected */ public function testConvertOptions($value, $options, $expected) { isSame($expected, Env::convert($value, $options)); }