RunnerManager::findChecks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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\Runner;
13
14
use Tvi\MonitorBundle\Check\CheckInterface;
15
use Tvi\MonitorBundle\Check\Group;
16
use Tvi\MonitorBundle\Check\CheckManager;
17
use Tvi\MonitorBundle\Check\Tag;
18
19
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
20
 * @author Vladimir Turnaev <[email protected]>
21
 */
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...
22
class RunnerManager
23
{
24
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
25
     * @var CheckManager
26
     */
27
    protected $checkManager;
28
29 94
    public function __construct(CheckManager $checkManager)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
30
    {
31 94
        $this->checkManager = $checkManager;
32 94
    }
33
34
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
35
     * @param ?string|string[] $ids
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     * @param ?string|string[] $groups
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
37
     * @param ?string|string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
38
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
39 62
    public function getRunner($ids = null, $groups = null, $tags = null): Runner
40
    {
41 62
        $checks = $this->checkManager->findChecks($ids, $groups, $tags);
42
43 62
        return new Runner(null, $checks);
44
    }
45
46
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
47
     * @param ?string|string[] $ids
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
48
     * @param ?string|string[] $groups
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
49
     * @param ?string|string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
50
     *
51
     * @return CheckInterface[]
52
     */
53 12
    public function findChecks($ids = null, $groups = null, $tags = null): array
54
    {
55 12
        return $this->checkManager->findChecks($ids, $groups, $tags);
56
    }
57
58
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
59
     * @param ?string|string[] $ids
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
60
     * @param ?string|string[] $groups
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
61
     * @param ?string|string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
62
     *
63
     * @return CheckInterface[]
64
     */
65 1
    public function findChecksSorted($ids = null, $groups = null, $tags = null): array
66
    {
67 1
        $checks = $this->findChecks($ids, $groups, $tags);
68
69 1
        uasort($checks, static function (CheckInterface $a, CheckInterface $b) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
70 1
            return ($a->getGroup() === $b->getGroup()) ? 0 : ($a->getGroup() < $b->getGroup() ? -1 : 1);
71 1
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
72
73 1
        return $checks;
74
    }
75
76
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
77
     * @param ?string|string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
78
     *
79
     * @return Tag[]
80
     */
81 12
    public function findTags($tags = null): array
82
    {
83 12
        return $this->checkManager->findTags($tags);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->checkManager->findTags($tags) returns an array which contains values of type Tvi\MonitorBundle\Check\Group which are incompatible with the documented value type Tvi\MonitorBundle\Check\Tag.
Loading history...
84
    }
85
86
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
87
     * @param ?string|string[] $groups
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
88
     *
89
     * @return Group[]
90
     */
91 11
    public function findGroups($groups = null): array
92
    {
93 11
        return $this->checkManager->findGroups($groups);
94
    }
95
}
96