Esempio n. 1
0
 public function getResolverBlock()
 {
     // strategy 1. Use resolver block.
     if (preg_match(self::V2_RESOLVER_BLOCK_REGEX, $this->sql, $matches)) {
         try {
             $json = new Json($matches[1]);
             $get = $json->get();
         } catch (BadJsonException $e) {
             throw new BadSqlResolverBlock($this, $matches[0]);
         }
         return $get;
     }
     throw new \Exception("You need a docblock comment for asset '{$this->id}'");
 }
Esempio n. 2
0
 /**
  * Set entity json property
  * @param mixed $json
  * @return Json
  */
 public static function set_Json($json, $inputValidate)
 {
     if ($json instanceof Json) {
         return $json;
     } elseif (null === $json) {
         return null;
     } elseif (!is_string($json)) {
         return Json::makeFromObject($json);
     }
     return new Json($json, $inputValidate);
 }
Esempio n. 3
0
 public function testMakeFromObject()
 {
     $obj = new \stdClass();
     $json = Json::makeFromObject($obj);
     $this->assertTrue($json instanceof Json);
     $this->assertTrue($json->isValid());
     $this->assertSame($obj, $json->get());
     $this->assertSame((string) $json, '{}');
 }