コード例 #1
0
ファイル: BinderObject.php プロジェクト: byjg/serializer
 /**
  * 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
ファイル: ResponseBag.php プロジェクト: byjg/restserver
 /**
  * @return array
  */
 public function process()
 {
     $collection = (array) $this->collection;
     if (count($collection) === 1) {
         $collection = $collection[0];
     }
     $object = new SerializerObject($collection);
     return $object->build();
 }
コード例 #3
0
ファイル: ModelTest.php プロジェクト: byjg/anydataset
 public function testIterator()
 {
     $model = new AnyDataset();
     $model->AddField("id", 10);
     $model->AddField("name", 'Testing');
     $model->appendRow();
     $model->AddField("id", 20);
     $model->AddField("name", 'Other');
     $iterator = $model->getIterator();
     $object = new SerializerObject($iterator->toArray());
     $result = $object->build();
     $this->assertEquals([["id" => 10, "name" => "Testing"], ["id" => 20, "name" => "Other"]], $result);
 }
コード例 #4
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);
 }