Completed
Push — master ( 38e077...1d4dc2 )
by brian
03:43 queued 02:03
created

LogicalAnd::isSatisfiedBy()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 6
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
    public function __construct(VersionRangeInterface $leftRange, VersionRangeInterface $rightRange)
39
    {
40
        $this->leftRange = $leftRange;
41
        $this->rightRange = $rightRange;
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47
    public function isSatisfiedBy(VersionInterface $version)
48
    {
49
        return $this->leftRange->isSatisfiedBy($version) && $this->rightRange->isSatisfiedBy($version);
50
    }
51
52
53
    /**
54
     * {@inheritDoc}
55
     */
56
    public function __toString()
57
    {
58
        return $this->leftRange . ',' . $this->rightRange;
59
    }
60
}
61