Completed
Push — master ( 70f96e...85b25a )
by Andrey
02:36
created

DeleteCollection::isCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
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/form-comparator
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\FormComparator\Comparator\Diff;
7
8
use Nnx\FormComparator\Comparator\DiffElementBuilder;
9
use Zend\Form\Element\Collection;
10
11
/**
12
 * Class DeleteCollection
13
 *
14
 * @package Nnx\FormComparator\Comparator\Diff
15
 */
16
class DeleteCollection extends AbstractDiffElement implements DeletedElementInterface
17
{
18
    /**
19
     * Удаленная коллекция
20
     *
21
     * @var Collection
22
     */
23
    private $deletedCollection;
24
25
    /**
26
     * Элементы удаленной коллекции
27
     *
28
     * @var DeleteElement[]
29
     */
30
    private $deletedElements = [];
31
32
    /**
33
     * Возвращает элементы удаленной коллекции
34
     *
35
     * @return DeleteElement[]
36
     */
37
    public function getDeletedElements()
38
    {
39
        return $this->deletedElements;
40
    }
41
    /**
42
     * Возвращает удаленную коллекцию
43
     *
44
     * @return Collection
45
     */
46
    public function getDeletedCollection()
47
    {
48
        return $this->deletedCollection;
49
    }
50
51
    /**
52
     * InsertElement constructor.
53
     *
54
     * @param DiffElementBuilder $diffBuilder
55
     */
56
    public function __construct(DiffElementBuilder $diffBuilder)
57
    {
58
        $this->deletedCollection = $diffBuilder->getTargetElement();
59
60
        parent::__construct($diffBuilder);
61
    }
62
63
64
    /**
65
     * Определяет является ли diff для коллекции или для элемента формы
66
     *
67
     * @return bool
68
     */
69
    public function isCollection()
70
    {
71
        return true;
72
    }
73
74
75
    /**
76
     * Определяет какое действие было соверешенно с элементом (элемент был добавлен, изменен, удален)
77
     *
78
     * @return bool
79
     */
80
    public function getMode()
81
    {
82
        return self::DELETE;
83
    }
84
}
85