Completed
Push — master ( bbff6f...c51acf )
by Rafał
19:14 queued 09:31
created

CollectionRepresentation::getResources()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SWP\Component\Common\Representation;
6
7
use Hateoas\Configuration\Annotation as Hateoas;
8
use JMS\Serializer\Annotation as Serializer;
9
10
/**
11
 * @Serializer\ExclusionPolicy("all")
12
 * @Serializer\XmlRoot("collection")
13
 *
14
 * @Hateoas\Relation(
15
 *     "_items",
16
 *     embedded = @Hateoas\Embedded("expr(object.getResources())")
17
 * )
18
 */
19
class CollectionRepresentation
20
{
21
    /**
22
     * @var mixed
23
     */
24
    private $resources;
25
26
    /**
27
     * @param array|\Traversable $resources
28
     */
29
    public function __construct($resources)
30
    {
31
        if ($resources instanceof \Traversable) {
32
            $resources = iterator_to_array($resources);
33
        }
34
35
        $this->resources = $resources;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public function getResources()
42
    {
43
        return $this->resources;
44
    }
45
}
46