Пример #1
0
 /**
  * Get all properties from a source object as an associative array
  *
  * @param mixed $source
  * @param bool $firstLevel
  * @return array
  */
 public static function toArrayFrom($source, $firstLevel = false)
 {
     // Prepare the source object type
     $object = new SerializerObject($source);
     $object->setStopFirstLevel($firstLevel);
     return $object->build();
 }
Пример #2
0
 public function testFirstLevel_2()
 {
     $model = new stdClass();
     $model->Obj = [10, 'Joao', new ModelGetter(20, 'JG')];
     $object = new SerializerObject($model);
     $object->setStopFirstLevel(true);
     $result = $object->build();
     $this->assertEquals(["Obj" => [10, 'Joao', new ModelGetter(20, 'JG')]], $result);
 }