Passed
Push — master ( 3bceb6...12b03a )
by Seth
02:10
created

Parameters::scopeExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Battis\SharedLogs\Database;
4
5
class Parameters
6
{
7
    /** Canonical name for field in additional request parameters containing the list of additional sub-objects */
8
    const SCOPE_INCLUDE = 'include';
9
10
    protected static function consumeParameterValue($params, $scope, $value)
11
    {
12
        if (self::parameterValueExists($params, $scope, $value)) {
13
            $params[$scope] = array_splice($params[$scope], array_search($value, $params[$scope]));
14
        }
15
        return $params; // for chaining
16
    }
17
18
    protected static function parameterValueExists($params, $scope, $value)
19
    {
20
        return !empty($params[$scope]) && is_array($params[$scope]) && in_array($value, $params[$scope]);
21
    }
22
23
    protected static function scopeExists($params, $scope)
24
    {
25
        return !empty($params[$scope]);
26
    }
27
28
    protected static function getScope($params, $scope)
29
    {
30
        if (self::scopeExists($params, $scope)) {
31
            return $params[$scope];
32
        }
33
        return null;
34
    }
35
}