InputDataValidator::ensureInputDataAreValid()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 3
eloc 6
nc 4
nop 3
1
<?php
2
/**
3
 * @author Boris Guéry <[email protected]>
4
 */
5
6
namespace Bgy\OAuth2\Utils;
7
8
use Bgy\OAuth2\GrantType\MissingOrInvalidInputData;
9
10
class InputDataValidator
11
{
12
    public static function ensureInputDataAreValid($grantTypeIdentifier, array $inputData, array $requiredDataKeys)
13
    {
14
        // check if we got the actual input data or just its keys
15
16
        $inputDataKeys = $inputData;
17
18
        if (array_keys($inputData) !== range(0, count($inputData) - 1)) {
19
            $inputDataKeys = array_keys($inputData);
20
        }
21
22
        // using == instead of === does not check the order of the properties
23
        if ($inputDataKeys == $requiredDataKeys) {
24
25
            throw new MissingOrInvalidInputData($grantTypeIdentifier, $inputDataKeys, $requiredDataKeys);
26
        }
27
    }
28
}
29