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

Parameters   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A consumeParameterValue() 0 7 2
A parameterValueExists() 0 4 3
A scopeExists() 0 4 1
A getScope() 0 7 2
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
}