Exemplo n.º 1
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);
 }
Exemplo n.º 2
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, '{}');
 }