SymfonyRequirements::check()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 7
cp 0
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
namespace Liip\MonitorBundle\Check;
4
5
use Laminas\Diagnostics\Check\CheckInterface;
6
use Laminas\Diagnostics\Result\Failure;
7
use Laminas\Diagnostics\Result\Success;
8
use Laminas\Diagnostics\Result\Warning;
9
10
/**
11
 * @author Kevin Bond <[email protected]>
12
 */
13
class SymfonyRequirements implements CheckInterface
14
{
15 1
    public function __construct($file)
16
    {
17 1
        if (!file_exists($file)) {
18
            throw new \InvalidArgumentException(sprintf('The file "%s" does not exist.', $file));
19
        }
20
21 1
        require $file;
22 1
    }
23
24
    public function check()
25
    {
26
        $symfonyRequirements = new \SymfonyRequirements();
27
28
        if (count($symfonyRequirements->getFailedRequirements())) {
29
            return new Failure('Some Symfony2 requirements are not met.');
30
        }
31
32
        if (count($symfonyRequirements->getFailedRecommendations())) {
33
            return new Warning('Some Symfony2 recommendations are not met.');
34
        }
35
36
        return new Success();
37
    }
38
39
    public function getLabel()
40
    {
41
        return 'Symfony2 Requirements';
42
    }
43
}
44