Check::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
/**
4
 * This file is part of the `tvi/monitor-bundle` project.
5
 *
6
 * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace Tvi\MonitorBundle\Check\php\ExtensionNotLoaded;
13
14
use JMS\Serializer\Annotation as JMS;
15
use ZendDiagnostics\Result\Failure;
16
use ZendDiagnostics\Result\ResultInterface;
17
use ZendDiagnostics\Result\Success;
18
use ZendDiagnostics\Check\ExtensionLoaded;
19
use Tvi\MonitorBundle\Check\CheckAbstract;
20
21
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
22
 * @JMS\ExclusionPolicy("all")
23
 *
24
 * @author Vladimir Turnaev <[email protected]>
25
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
26
class Check extends CheckAbstract
27
{
28
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
29
     * @var ExtensionLoaded
30
     */
31
    private $checker;
0 ignored issues
show
Coding Style introduced by
Private member variable "checker" must be prefixed with an underscore
Loading history...
32
33
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
34
     * @param int|string $size minimum disk size in bytes or a valid byte string (IEC, SI or Jedec)
35
     * @param string     $path The disk path to check, i.e. '/tmp' or 'C:' (defaults to /)
36
     *
37
     * @throws \InvalidArgumentException
38
     */
39 2
    public function __construct($size, $path = '/')
40
    {
41 2
        $this->checker = new ExtensionLoaded($size, $path);
0 ignored issues
show
Unused Code introduced by
The call to ZendDiagnostics\Check\Ex...onLoaded::__construct() has too many arguments starting with $path. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        $this->checker = /** @scrutinizer ignore-call */ new ExtensionLoaded($size, $path);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
42 2
    }
43
44
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
45
     * @return Failure|Success|ResultInterface
46
     */
47 2
    public function check()
48
    {
49 2
        $r = $this->checker->check();
50 2
        if ($r instanceof Success) {
51 2
            return new Failure($r->getMessage(), $r->getData());
52
        }
53
54 1
        return new Success($r->getMessage(), $r->getData());
55
    }
56
}
57