DataContainer::getIndex()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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 DataContainer
10
 *
11
 * @package Nnx\JmsSerializerModule\DataContainer
12
 */
13
class DataContainer implements DataContainerInterface
14
{
15
    /**
16
     * Внутренний идендификатор контейнера с данынми для фикстуры
17
     *
18
     * @var integer
19
     */
20
    protected $id;
21
22
    /**
23
     * Поле используемое для генерации id
24
     *
25
     * @var int
26
     */
27
    protected static $idGenerator = 0;
28
29
    /**
30
     * @var EntityInterface[]
31
     */
32
    protected $entities = [];
33
34
    /**
35
     * Хранилище индексов
36
     *
37
     * @var Index
38
     */
39
    protected $index;
40
41
    /**
42
     * DataContainer constructor.
43
     *
44
     * @param Index $index
45
     */
46
    public function __construct(Index $index)
47
    {
48
        $this->index = $index;
49
    }
50
51
    /**
52
     * Добавляет информацию о данных для сущности
53
     *
54
     * @param EntityInterface $entity
55
     *
56
     * @return $this
57
     */
58
    public function addEntity(EntityInterface $entity)
59
    {
60
        $this->index->indexEntity($entity);
61
        $this->entities[] = $entity;
62
63
        return $this;
64
    }
65
66
    /**
67
     * Возвращает список контейнеров с данными для заполнения бд
68
     *
69
     * @return EntityInterface[]
70
     */
71
    public function getEntities()
72
    {
73
        return $this->entities;
74
    }
75
76
    /**
77
     * Возвращает хранилище индексов
78
     *
79
     * @return Index
80
     */
81
    public function getIndex()
82
    {
83
        return $this->index;
84
    }
85
86
87
    /**
88
     * Возвращает внутренний идендификатор контейнера
89
     *
90
     * @return int
91
     */
92 View Code Duplication
    public function getId()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
93
    {
94
        if (null === $this->id) {
95
            static::$idGenerator += 1;
96
            $this->id = static::$idGenerator;
97
        }
98
        return $this->id;
99
    }
100
}
101