diff --git a/src/ValueAs.php b/src/ValueAs.php index 490db41..2ce5df0 100644 --- a/src/ValueAs.php +++ b/src/ValueAs.php @@ -158,16 +158,13 @@ public static function arr($value, $default = []) if(is_string($value)) { - if(strpos($value, '=') !== false && strpos($value, '&') !== false) + if(strpos($value, '=') !== false) { $array = []; - foreach(explode('&', $value) as $set) - { - list($key, $val) = explode('=', $set, 2); - $array[$key] = $val; - } + parse_str($value, $array); return $array; } + if(strpos($value, ',') !== false) { return explode(',', $value); diff --git a/tests/DateTimeHelperTest.php b/tests/DateTimeHelperTest.php index 80ee858..8565b1d 100644 --- a/tests/DateTimeHelperTest.php +++ b/tests/DateTimeHelperTest.php @@ -154,7 +154,7 @@ public function uniqidProvider() public function testMilliseconds() { - static::assertIsInt(DateTimeHelper::milliseconds()); + static::assertInternalType('int', DateTimeHelper::milliseconds()); } public function testToSeconds() diff --git a/tests/SystemTest.php b/tests/SystemTest.php index d24085a..a2afe35 100644 --- a/tests/SystemTest.php +++ b/tests/SystemTest.php @@ -24,9 +24,9 @@ protected function tearDown(): void public function testGlobals() { - static::assertIsBool(System::isHHVM()); - static::assertIsBool(System::isMac()); - static::assertIsBool(System::isWindows()); + static::assertInternalType('bool', System::isHHVM()); + static::assertInternalType('bool', System::isMac()); + static::assertInternalType('bool', System::isWindows()); } public function testIsAppEngine() @@ -61,7 +61,7 @@ public function testIsBuiltInWebServer() public function testCommandFinder() { - static::assertIsBool(System::commandExists('whois')); + static::assertInternalType('bool', System::commandExists('whois')); if(System::isWindows()) { static::assertTrue(System::commandExists('explorer')); diff --git a/tests/ValueAsTest.php b/tests/ValueAsTest.php index 868b2f1..397200f 100644 --- a/tests/ValueAsTest.php +++ b/tests/ValueAsTest.php @@ -18,10 +18,7 @@ class ValueAsTest extends TestCase */ public function testExactConversions($method, $value, $default, $expect) { - static::assertSame( - $expect, - ValueAs::$method($value, $default) - ); + static::assertSame($expect, ValueAs::$method($value, $default)); } /** @@ -76,6 +73,7 @@ public function exactProvider() ['arr', "hey", null, ["hey"]], ['arr', "hello,world", null, ["hello", "world"]], ['arr', "test=one&unit=two", null, ["test" => 'one', "unit" => 'two']], + ['arr', "test=one", null, ["test" => 'one']], ['arr', "", ["test"], ["test"]], ['arr', tmpfile(), ["test"], ["test"]], ['arr', $objectTest, ["test"], ["item" => "value"]],