Completed
Push — master ( 549d74...5f8498 )
by Tim
02:25
created

Operation::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * TechDivision\Import\Cli\Configuration\Operation
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-cli-simple
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Cli\Configuration;
22
23
use JMS\Serializer\Annotation\Type;
24
use JMS\Serializer\Annotation\SerializedName;
25
use TechDivision\Import\Configuration\SubjectInterface;
26
use TechDivision\Import\ConfigurationInterface;
27
use TechDivision\Import\Configuration\OperationInterface;
28
29
/**
30
 * The configuration implementation for the options.
31
 *
32
 * @author    Tim Wagner <[email protected]>
33
 * @copyright 2016 TechDivision GmbH <[email protected]>
34
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
35
 * @link      https://github.com/techdivision/import-cli-simple
36
 * @link      http://www.techdivision.com
37
 */
38
class Operation implements OperationInterface
39
{
40
41
    /**
42
     * The operation's name.
43
     *
44
     * @var string
45
     * @Type("string")
46
     */
47
    protected $name;
48
49
    /**
50
     * ArrayCollection with the information of the configured subjects.
51
     *
52
     * @var \Doctrine\Common\Collections\ArrayCollection
53
     * @Type("ArrayCollection<TechDivision\Import\Cli\Configuration\Subject>")
54
     */
55
    protected $subjects;
56
57
    /**
58
     * Initialize the operation with the passed name.
59
     *
60
     * @param string|null $name The operation name
61
     */
62
    public function __construct($name = null)
63
    {
64
        if ($name != null) {
0 ignored issues
show
Bug introduced by
It seems like you are loosely comparing $name of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
65
            $this->name = $name;
66
        }
67
    }
68
69
    /**
70
     * Query's whether or not the passed operation equals this instance.
71
     *
72
     * @param \TechDivision\Import\Cli\Configuration\Operation $operation The operation to query
73
     *
74
     * @return boolean TRUE if the operations are equal, else FALSE
75
     */
76
    public function equals(OperationInterface $operation)
77
    {
78
        return strcasecmp($this->getName(), $operation->getName()) === 0;
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
79
    }
80
81
    /**
82
     * Return's the operation's name.
83
     *
84
     * @return string The operation's class name
85
     */
86
    public function getName()
87
    {
88
        return $this->name;
89
    }
90
91
    /**
92
     * Return's the ArrayCollection with the operation's subjects.
93
     *
94
     * @return \Doctrine\Common\Collections\ArrayCollection The ArrayCollection with the operation's subjects
95
     */
96
    public function getSubjects()
97
    {
98
        return $this->subjects;
99
    }
100
101
    /**
102
     * String representation of the operation (the name).
103
     *
104
     * @return string The operation name
105
     */
106
    public function __toString()
107
    {
108
        return $this->getName();
0 ignored issues
show
Bug introduced by
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
109
    }
110
}
111