TraitCommon   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 10
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilterParam() 0 8 4
A getFilterParams() 0 8 1
1
<?php
2
3
/**
4
 * This file is part of the `tvi/monitor-bundle` project.
5
 *
6
 * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace Tvi\MonitorBundle\Controller;
13
14
use Symfony\Component\HttpFoundation\Request;
15
16
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
17
 * @author Vladimir Turnaev <[email protected]>
18
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
19
trait TraitCommon
20
{
21 58
    protected function getFilterParam(Request $request, $name)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getFilterParam()
Loading history...
22
    {
23 58
        $v = $request->get($name, []);
24 58
        if (\is_scalar($v)) {
25 28
            $v = $v ? [$v] : [];
26
        }
27
28 58
        return !\is_array($v) ? [$v] : $v;
29
    }
30
31
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $request should have a doc-comment as per coding-style.
Loading history...
32
     * return array [$ids, $checks, $groups, $tags].
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
33
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
34 58
    protected function getFilterParams(Request $request): array
35
    {
36 58
        $ids = $this->getFilterParam($request, 'id');
37 58
        $checks = $this->getFilterParam($request, 'check');
38 58
        $groups = $this->getFilterParam($request, 'group');
39 58
        $tags = $this->getFilterParam($request, 'tag');
40
41 58
        return [$ids, $checks, $groups, $tags];
42
    }
43
}
44