Validator::validate()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
nc 1
nop 1
dl 0
loc 9
ccs 0
cts 2
cp 0
crap 12
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Samerior\MobileMoney\Equity\Library;
4
5
class Validator
6
{
7
    /**
8
     * Required keys.
9
     *
10
     * @var array
11
     */
12
    const RULES = [
13
        'VA_PAYBILL',
14
        'VA_PASSWORD',
15
        'VA_TIMESTAMP',
16
        'VA_TRANS_ID',
17
        'VA_REF_ID',
18
        'VA_AMOUNT',
19
        'VA_NUMBER',
20
        'VA_CALL_URL',
21
        'VA_CALL_METHOD'
22
    ];
23
24
    /**
25
     * Check if key exists else throw exception.
26
     *
27
     * @param array $data
28
     *
29
     * @return bool
30
     * @throws InvalidRequestException
31
     */
32
    public static function validate($data = [])
0 ignored issues
show
Unused Code introduced by
The parameter $data 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...
33
    {
34
        return true;
35
        foreach (static::RULES as $value) {
0 ignored issues
show
Unused Code introduced by
foreach (static::RULES a...RRORS[$value]); } } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
36
            if (!array_key_exists($value, $data)) {
37
                throw new InvalidRequestException(InvalidRequestException::ERRORS[$value]);
38
            }
39
        }
40
    }
41
}
42