/** * @test */ public function canReplaceExistingRecognition() { Parse::addRecognition(function ($string) { if ('Binford 6100' === $string) { return true; } }, 'booleanTrue'); assertTrue(Parse::toType('Binford 6100')); }
/** * @test */ public function parseRecognizesHttpsUris() { assert(Parse::toType('https://example.net/'), equals(HttpUri::fromString('https://example.net/'))); }
/** * parses value to correct type * * @param string $value * @return mixed */ private function parseType(string $value) { if (substr($value, 0, 1) === '"' && substr($value, -1) === '"' || substr($value, 0, 1) === "'" && substr($value, -1) === "'") { return substr($value, 1, strlen($value) - 2); } return Parse::toType($value); }