Completed
Push — master ( 99ca87...95904e )
by Andrey
23:44
created

Association   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 82
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A setName() 0 6 1
A addEntity() 0 7 1
A getEntities() 0 4 1
1
<?php
2
/**
3
 * @link    https://github.com/nnx-framework/jms-serializer-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\JmsSerializerModule\DataContainer;
7
8
/**
9
 * Class Association
10
 *
11
 * @package Nnx\JmsSerializerModule\DataContainer
12
 */
13
class Association
14
{
15
    /**
16
     * Имя ассоциаци
17
     *
18
     * @var string
19
     */
20
    protected $name;
21
22
    /**
23
     * Сущности на которые указывает связь
24
     *
25
     * @var EntityInterface[]
26
     */
27
    protected $entities;
28
29
    /**
30
     * Хранилище индексов
31
     *
32
     * @var Index
33
     */
34
    protected $index;
35
36
    /**
37
     * Association constructor.
38
     *
39
     * @param Index $index
40
     */
41
    public function __construct(Index $index)
42
    {
43
        $this->index = $index;
44
    }
45
46
    /**
47
     * Устанавливает имя ассоциаци
48
     *
49
     * @return string
50
     */
51
    public function getName()
52
    {
53
        return $this->name;
54
    }
55
56
    /**
57
     * Возвращает имя ассоциаци
58
     *
59
     * @param string $name
60
     *
61
     * @return $this
62
     */
63
    public function setName($name)
64
    {
65
        $this->name = $name;
66
67
        return $this;
68
    }
69
70
    /**
71
     * Добавляет контейнер с данными о вложенной сущности
72
     *
73
     * @param EntityInterface $entity
74
     *
75
     * @return $this
76
     */
77
    public function addEntity(EntityInterface $entity)
78
    {
79
        $this->index->indexEntity($entity);
80
        $this->entities[] = $entity;
81
82
        return $this;
83
    }
84
85
    /**
86
     * Возвращает контейнер с данными о вложенных сущностях
87
     *
88
     * @return EntityInterface[]
89
     */
90
    public function getEntities()
91
    {
92
        return $this->entities;
93
    }
94
}
95