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

DeleteCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeletedElements() 0 4 1
A getDeletedCollection() 0 4 1
A __construct() 0 6 1
A isCollection() 0 4 1
A getMode() 0 4 1
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