Tobscure\JsonApi\Collection::toArray PHP Метод

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

public toArray ( )
    public function toArray()
    {
        return array_map(function (Resource $resource) {
            return $resource->toArray();
        }, $this->resources);
    }

Usage Example

Пример #1
0
 public function testToArrayReturnsArrayOfResources()
 {
     $serializer = new PostSerializer3();
     $post1 = (object) ['id' => 1, 'foo' => 'bar'];
     $post2 = new Resource((object) ['id' => 2, 'foo' => 'baz'], $serializer);
     $collection = new Collection([$post1, $post2], $serializer);
     $resource1 = new Resource($post1, $serializer);
     $resource2 = $post2;
     $this->assertEquals([$resource1->toArray(), $resource2->toArray()], $collection->toArray());
 }