Esempio n. 1
0
 /**
  * @param $value
  * @param int $adapter
  * @return Smart
  */
 private static function updateMapper($value, $adapter = Mapper::MEMORY_ANNOTATION_ADAPTER)
 {
     if (is_null(self::$mapper)) {
         self::$mapper = new Smart($value, get_called_class(), $adapter);
     } else {
         self::$mapper->setInputValue($value)->setAnnotationAdapterType($adapter);
     }
     return self::$mapper;
 }
Esempio n. 2
0
 /**
  * @return void
  */
 public function testReusable()
 {
     $mapper = new Smart(self::getTreeDecodedToArray(), new Tree(), Mapper::FILES_ANNOTATION_ADAPTER);
     $objectMapped = $mapper->map();
     $this->assertEquals($objectMapped, self::getTree());
     $objectMapped = $mapper->setInputValue(self::getBranchJson())->setOutputObject(new Branch())->setAnnotationAdapterType(Mapper::MEMORY_ANNOTATION_ADAPTER)->map();
     $this->assertEquals($objectMapped, self::getBranch());
     $objectMapped = $mapper->setInputValue(self::getTreeDecodedToObject())->setOutputObject(new Tree())->setAnnotationAdapterType(Mapper::FILES_ANNOTATION_ADAPTER)->map();
     $this->assertEquals($objectMapped, self::getTree());
 }