LogicalAnd::isSatisfiedBy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 1
crap 2
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
    /** @var VersionRangeInterface */
22
    private $leftRange;
23
24
    /** @var VersionRangeInterface */
25
    private $rightRange;
26
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param VersionRangeInterface $leftRange
32
     * @param VersionRangeInterface $rightRange
33
     */
34 2
    public function __construct(VersionRangeInterface $leftRange, VersionRangeInterface $rightRange)
35
    {
36 2
        $this->leftRange = $leftRange;
37 2
        $this->rightRange = $rightRange;
38 2
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43 1
    public function isSatisfiedBy(VersionInterface $version)
44
    {
45 1
        return $this->leftRange->isSatisfiedBy($version) && $this->rightRange->isSatisfiedBy($version);
46
    }
47
48
49
    /**
50
     * {@inheritDoc}
51
     */
52 1
    public function __toString()
53
    {
54 1
        return $this->leftRange . ',' . $this->rightRange;
55
    }
56
}
57