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

CollectionRepresentation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getResources() 0 4 1
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