Passed
Push — master ( 8bd994...8bfb27 )
by Théo
02:28
created

IsPhpVersionFulfilled   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the box project.
5
 *
6
 * (c) Kevin Herrera <[email protected]>
7
 *     Théo Fidry <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace KevinGH\RequirementChecker;
14
15
use Composer\Semver\Semver;
16
17
/**
18
 * @private
19
 */
20
final class IsPhpVersionFulfilled implements IsFulfilled
21
{
22
    private $requiredPhpVersion;
23
24
    /**
25
     * @param string $requiredPhpVersion
26
     */
27
    public function __construct($requiredPhpVersion)
28
    {
29
        $this->requiredPhpVersion = $requiredPhpVersion;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function __invoke()
36
    {
37
        return Semver::satisfies(
38
            sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION),
39
            $this->requiredPhpVersion
40
        );
41
    }
42
}
43