Completed
Push — master ( 1d2321...475c0f )
by brian
02:39
created

LogicalAnd   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
cbo 1
dl 0
loc 42
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isSatisfiedBy() 0 4 2
A __toString() 0 4 1
1
<?php
2
3
/**
4
 * @copyright   (c) 2014-2017 brian ridley
5
 * @author      brian ridley <[email protected]>
6
 * @license     http://opensource.org/licenses/MIT MIT
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 ptlis\SemanticVersion\VersionRange;
13
14
use ptlis\SemanticVersion\Version\VersionInterface;
15
16
/**
17
 * Version range with a left & right value - both must be true to fulfill the isSatisfiedBy requirement.
18
 */
19
final class LogicalAnd implements VersionRangeInterface
20
{
21
    /**
22
     * @var VersionRangeInterface
23
     */
24
    private $leftRange;
25
26
    /**
27
     * @var VersionRangeInterface
28
     */
29
    private $rightRange;
30
31
32
    /**
33
     * Constructor.
34
     *
35
     * @param VersionRangeInterface $leftRange
36
     * @param VersionRangeInterface $rightRange
37
     */
38 2
    public function __construct(VersionRangeInterface $leftRange, VersionRangeInterface $rightRange)
39
    {
40 2
        $this->leftRange = $leftRange;
41 2
        $this->rightRange = $rightRange;
42 2
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 1
    public function isSatisfiedBy(VersionInterface $version)
48
    {
49 1
        return $this->leftRange->isSatisfiedBy($version) && $this->rightRange->isSatisfiedBy($version);
50
    }
51
52
53
    /**
54
     * {@inheritDoc}
55
     */
56 1
    public function __toString()
57
    {
58 1
        return $this->leftRange . ',' . $this->rightRange;
59
    }
60
}
61