ParamGetter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 7
c 2
b 1
f 0
dl 0
loc 25
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getParam() 0 15 4
1
<?php
2
3
namespace Sfneal\Queries\Traits;
4
5
use Illuminate\Http\Request;
6
7
trait ParamGetter
8
{
9
    /**
10
     * Retrieve a parameter that can be set by a variable or request input.
11
     *
12
     * @param Request|null $request
13
     * @param array $parameters
14
     * @param null $key
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $key is correct as it would always require null to be passed?
Loading history...
15
     * @return mixed|null
16
     */
17
    private static function getParam(Request $request = null, array $parameters = [], $key = null)
18
    {
19
        // Parameter is specified
20
        if (array_key_exists($key, $parameters)) {
21
            return $parameters[$key];
22
        }
23
24
        // Param is not specified but the $request has the $key
25
        elseif ($request && $request->has($key)) {
26
            return $request->input($key);
27
        }
28
29
        // Not parameter passed
30
        else {
31
            return null;
32
        }
33
    }
34
}
35