IncludedObjectsContainer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 42
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addIncludedObject() 0 4 1
A addIncludedIterator() 0 7 2
A getIncludedObjects() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Bundle\JsonApiBundle\Response\Behaviour;
5
6
/**
7
 * Behaviour of a container of included objects
8
 *
9
 * @package Mikemirten\Bundle\JsonApiBundle\Response\Behaviour
10
 */
11
trait IncludedObjectsContainer
12
{
13
    /**
14
     * Objects supposed to be included to document
15
     *
16
     * @var array
17
     */
18
    protected $includedObjects = [];
19
20
    /**
21
     * Add included object to document
22
     *
23
     * @param mixed $object
24
     */
25 1
    public function addIncludedObject($object)
26
    {
27 1
        $this->includedObjects[] = $object;
28 1
    }
29
30
    /**
31
     * Add an iterator contains objects should be included
32
     *
33
     * @param \Traversable $iterator
34
     */
35 1
    public function addIncludedIterator(\Traversable $iterator)
36
    {
37 1
        foreach ($iterator as $object)
38
        {
39 1
            $this->includedObjects[] = $object;
40
        }
41 1
    }
42
43
    /**
44
     * Get objects included to document
45
     *
46
     * @return array
47
     */
48 3
    public function getIncludedObjects(): array
49
    {
50 3
        return $this->includedObjects;
51
    }
52
}