Completed
Push — master ( f98365...7d52cd )
by Saurabh
10:18
created

InputChecker::validateHasKeys()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Sausin\Signere\Concerns;
4
5
use BadMethodCallException;
6
7
trait InputChecker
8
{
9
    /**
10
     * Check that the input has needed keys.
11
     *
12
     * @param  array  &$input
13
     * @param  array  &$keys
14
     * @return \BadMethodCallException|void
15
     */
16 12
    protected function validateHasKeys(array &$input, array &$keys)
17
    {
18 12
        if (! array_has_all_keys($input, $keys)) {
19 5
            throw new BadMethodCallException(
20 5
                'Missing fields in input array. Need '.implode(', ', $keys)
21
            );
22
        }
23 12
    }
24
}
25