Completed
Push — develop ( 9659b8...659b85 )
by Mathias
13:02
created

DependencyResult   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 0
loc 85
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 5
A getName() 0 4 1
A getEntities() 0 4 1
A getViewScript() 0 4 1
A getDescription() 0 4 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2018 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Core\Service\EntityEraser;
12
13
/**
14
 * DependecyResult ValueObject.
15
 * 
16
 * @author Mathias Gelhausen <[email protected]>
17
 * @todo write test 
18
 */
19
class DependencyResult 
20
{
21
    /**
22
     * Name of this result.
23
     *
24
     * @var string
25
     */
26
    private $name;
27
28
    /**
29
     * Entities collection.
30
     *
31
     * @var array|\Traversable
32
     */
33
    private $entities;
34
35
    /**
36
     * ViewScript to render the entity list with.
37
     *
38
     * @var string
39
     */
40
    private $viewScript;
41
42
    /**
43
     * Description
44
     *
45
     * @var string
46
     */
47
    private $description;
48
49
    /**
50
     * DependencyResult constructor.
51
     *
52
     * There are two valid options:
53
     * - 'description': Sets the description.
54
     * - 'viewScript': Sets the view script.
55
     *
56
     * @param string     $name
57
     * @param array|\Traversable  $entities
58
     * @param array|null $options
59
     */
60
    public function __construct($name, $entities, array $options = null)
61
    {
62
        if (!is_array($entities) && !$entities instanceOf \Traversable) {
63
            throw new \InvalidArgumentException('Entities must be an array or an instance of \Traversable');
64
        }
65
66
        $this->name = (string) $name;
67
        $this->entities = $entities;
68
        $this->viewScript = isset($options['viewScript']) ? $options['viewScript'] : 'core/entity-eraser/dependency-list';
69
        $this->description = isset($options['description']) ? $options['description'] : '';
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getName()
76
    {
77
        return $this->name;
78
    }
79
80
    /**
81
     * @return array|\Traversable
82
     */
83
    public function getEntities()
84
    {
85
        return $this->entities;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getViewScript()
92
    {
93
        return $this->viewScript;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    public function getDescription()
100
    {
101
        return $this->description;
102
    }
103
}
104