Completed
Push — master ( f8d07f...897034 )
by Vladimir
05:58
created

TraitCommon   A

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
use JMS\Serializer\Serializer;
16
use Symfony\Component\HttpFoundation\Response;
17
use Tvi\MonitorBundle\Reporter\ReporterManager;
18
use Tvi\MonitorBundle\Runner\RunnerManager;
19
20
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
 * @author Vladimir Turnaev <[email protected]>
22
 */
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...
23
trait TraitCommon
24
{
25 57
    protected function getFilterParam(Request $request, $name)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getFilterParam()
Loading history...
26
    {
27 57
        $v = $request->get($name, []);
28 57
        if (\is_scalar($v)) {
29 28
            $v = $v ? [$v] : [];
30
        }
31
32 57
        return !\is_array($v) ? [$v] : $v;
33
    }
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $request should have a doc-comment as per coding-style.
Loading history...
36
     * 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...
37
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
38 57
    protected function getFilterParams(Request $request): array
39
    {
40 57
        $ids = $this->getFilterParam($request, 'id');
41 57
        $checks = $this->getFilterParam($request, 'check');
42 57
        $groups = $this->getFilterParam($request, 'group');
43 57
        $tags = $this->getFilterParam($request, 'tag');
44
45 57
        return [$ids, $checks, $groups, $tags];
46
    }
47
}
48