Version   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 69.57%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 0
dl 0
loc 93
ccs 16
cts 23
cp 0.6957
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A getBuild() 0 4 1
A setBuild() 0 6 1
A getName() 0 4 1
A setName() 0 6 1
A getUID() 0 4 1
A __toString() 0 4 1
A equals() 0 7 2
1
<?php
2
3
/*
4
 * This file is part of the Conveyor package.
5
 *
6
 * (c) Jeroen Fiege <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webcreate\Conveyor\Repository;
13
14
class Version
15
{
16
    /**
17
     * @var string
18
     */
19
    protected $name;
20
21
    /**
22
     * @var string
23
     */
24
    protected $build;
25
26
    /**
27
     * @param string|null $name
28
     * @param string|null $build
29
     */
30 4
    public function __construct($name = null , $build = null)
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces between argument "$name" and comma; 1 found
Loading history...
31
    {
32 4
        if (null !== $name) {
33 1
            $this->setName($name);
34
        }
35
36 4
        if (null !== $build) {
37 1
            $this->setBuild($build);
38
        }
39 4
    }
40
41
    /**
42
     * @return null|string
43
     */
44 1
    public function getBuild()
45
    {
46 1
        return $this->build;
47
    }
48
49
    /**
50
     * @param string $build
51
     * @return $this
52
     */
53 2
    public function setBuild($build)
54
    {
55 2
        $this->build = (string) $build;
56
57 2
        return $this;
58
    }
59
60
    /**
61
     * @return null|string
62
     */
63 1
    public function getName()
64
    {
65 1
        return $this->name;
66
    }
67
68
    /**
69
     * @param string $name
70
     * @return $this
71
     */
72 2
    public function setName($name)
73
    {
74 2
        $this->name = (string) $name;
75
76 2
        return $this;
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getUID()
83
    {
84
        return sprintf('%s:%s', $this->name, $this->build);
85
    }
86
87
    /**
88
     * @return string
89
     */
90
    public function __toString()
91
    {
92
        return $this->getUID();
93
    }
94
95
    /**
96
     * @param Version $version
97
     * @return bool
98
     */
99
    public function equals(Version $version)
100
    {
101
        return (
102
                $this->name === $version->getName()
103
            &&  $this->build === $version->getBuild()
104
        );
105
    }
106
}
107