Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#671)
by Michael
04:31
created

Method::hasReference()   A

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 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
use ReflectionMethod;
15
use Respect\Validation\Exceptions\ComponentException;
16
use Respect\Validation\Validatable;
17
18
class Method extends AbstractRelated
19
{
20
21
    /**
22
     * An array of arguments that should be passed to the method.
23
     *
24
     * @var array
25
     */
26
    protected $methodArgs = [];
27
28 15
    public function __construct($reference, Validatable $validator = null, $mandatory = true, $methodArgs = [])
0 ignored issues
show
Unused Code introduced by
The parameter $methodArgs is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
    {
30 15
        if(!is_string($reference) || empty($reference)) {
31 3
            throw new ComponentException('Invalid method name');
32
        }
33
34 12
        parent::__construct($reference, $validator, $mandatory);
35 12
    }
36
37 6
    public function getReferenceValue($input)
38
    {
39 6
        $methodMirror = new ReflectionMethod($input, $this->reference);
40 6
        $methodMirror->setAccessible(true);
41
42 6
        return $methodMirror->invokeArgs($input, $this->methodArgs);
43
    }
44
45 12
    public function hasReference($input)
46
    {
47 12
        return is_object($input) && method_exists($input, $this->reference);
48
    }
49
}
50