ComparatorVersion::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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\Comparator\ComparatorInterface;
15
use ptlis\SemanticVersion\Version\VersionInterface;
16
17
/**
18
 * Simple version number & comparator.
19
 */
20
final class ComparatorVersion implements VersionRangeInterface
21
{
22
    /** @var ComparatorInterface */
23
    private $comparator;
24
25
    /** @var VersionInterface */
26
    private $version;
27
28
29
    /**
30
     * Constructor.
31
     *
32
     * @param ComparatorInterface $comparator
33
     * @param VersionInterface $version
34
     */
35 2
    public function __construct(ComparatorInterface $comparator, VersionInterface $version)
36
    {
37 2
        $this->comparator = $comparator;
38 2
        $this->version = $version;
39 2
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 1
    public function isSatisfiedBy(VersionInterface $version)
45
    {
46 1
        return $this->comparator->compare($version, $this->version);
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52 1
    public function __toString()
53
    {
54 1
        return $this->comparator . $this->version;
55
    }
56
}
57