示例#1
0
 public function test_init()
 {
     $this->assertEquals([1, 2], F\init([1, 2, 3]));
     $this->assertEquals('Hell', F\init('Hello'));
     $this->assertEquals([], F\init([7]));
     $this->assertEquals([], F\init([]));
     $this->assertEquals('', F\init(''));
 }
示例#2
0
 /**
  * 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;
 }