Test Failed
Push — master ( 3e1f63...b2d2e1 )
by Vladimir
04:38
created

ApiInitTrait   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 11
eloc 21
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
C getFilterParams() 0 21 10
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
15
use JMS\Serializer\Serializer;
16
use Symfony\Component\HttpFoundation\Request;
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 ApiInitTrait
24
{
25
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
26
     * @var RunnerManager
27
     */
28
    protected $runnerManager;
29
30
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
31
     * @var ReporterManager
32
     */
33
    protected $reporterManager;
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
36
     * @var Serializer
37
     */
38
    protected $serializer;
39
40
    public function __construct(RunnerManager $runnerManager, ReporterManager $reporterManager, Serializer $serializer)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
41
    {
42
        $this->runnerManager = $runnerManager;
43
        $this->reporterManager = $reporterManager;
44
        $this->serializer  = $serializer;
45
46
        exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
47
    }
48
49
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $request should have a doc-comment as per coding-style.
Loading history...
50
     * return array [$checks, $groups, $tags].
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
51
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
52
    protected function getFilterParams(Request $request): array
53
    {
54
        $checks = $request->get('check', []);
55
        if (\is_scalar($checks)) {
56
            $checks = $checks ? [$checks] : [];
57
        }
58
        $checks = !\is_array($checks) ? [$checks] : $checks;
59
60
        $groups = $request->get('group', []);
61
        if (\is_scalar($groups)) {
62
            $groups = $groups ? [$groups] : [];
63
        }
64
        $groups = !\is_array($groups) ? [$groups] : $groups;
65
66
        $tags = $request->get('tag', []);
67
        if (\is_scalar($tags)) {
68
            $tags = $tags ? [$tags] : [];
69
        }
70
        $tags = !\is_array($tags) ? [$tags] : $tags;
71
72
        return [$checks, $groups, $tags];
73
    }
74
}
75