public function test_head() { $array = [1, 2, 3, 4]; $this->assertEquals(1, F\head($array)); $this->assertEquals('H', F\head('Hello')); $this->assertEquals(7, F\head([7])); $this->assertNull(F\head([])); $this->assertEquals('', F\head('')); }
/** * Transforms a string to syntax. * * @param string $text the string to parse * @return Tarsana\Syntax\Syntax */ protected function doParse($text) { $txt = $text; if (F\head($text) == '[' && F\last($text) == ']') { $txt = F\init(F\tail($text)); } if ($this->isObject($txt)) { return $this->parseObject($text); } if ($this->isArray($txt)) { return $this->parseArray($text); } if ($this->isNumber($txt)) { return $this->parseNumber($text); } if ($this->isBoolean($txt)) { return $this->parseBoolean($text); } if ($this->isString($txt)) { return $this->parseString($text); } return null; }