toDomainTypes() публичный Метод

Example: converts MongoDB\BSON\ObjectID to Type\ObjectID
public toDomainTypes ( array $data ) : mixed
$data array Array to convert.
Результат mixed
Пример #1
0
 public function testToDomainTypesShouldReplaceMongoTypesByDomainTypes()
 {
     $mongoId = new MongoObjectID();
     $timestamp = time();
     $mongoDate = new MongoUTCDateTime($timestamp * 1000);
     $id = new ObjectID($mongoId);
     $date = new UTCDateTime($timestamp);
     $data = ['_id' => $mongoId, 'created_at' => $mongoDate, 'parents' => [$mongoId, $mongoId, $mongoId], 'comments' => [['author' => 'Jhon', 'date' => $mongoDate], ['author' => 'Doe', 'date' => $mongoDate, 'versions' => [['_id' => $mongoId, 'date' => $mongoDate, 'content' => 'Awsome'], ['_id' => $mongoId, 'date' => $mongoDate, 'content' => 'Great']]]]];
     $expected = ['_id' => $id, 'created_at' => $date, 'parents' => [$id, $id, $id], 'comments' => [['author' => 'Jhon', 'date' => $date], ['author' => 'Doe', 'date' => $date, 'versions' => [['_id' => $id, 'date' => $date, 'content' => 'Awsome'], ['_id' => $id, 'date' => $date, 'content' => 'Great']]]]];
     $this->assertEquals($expected, $this->converter->toDomainTypes($data));
 }
Пример #2
0
 /**
  * Converts recursively the given objects (probably retrieved from MongoDB)
  * to our specific types.
  * Example: converts MongoDB\BSON\ObjectID to Type\ObjectID.
  *
  * @param array $attributes Array to convert.
  *
  * @return array
  */
 public function convert(array $attributes)
 {
     return $this->converter->toDomainTypes($attributes);
 }