CommandSet::assertValid()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace Equip\Console\Command;
4
5
use Equip\Console\Exception\CommandException;
6
use Equip\Structure\Set;
7
use Symfony\Component\Console\Command\Command;
8
9
class CommandSet extends Set
10
{
11
    /**
12
     * {@inheritdoc}
13
     *
14
     * @throws CommandException If $commands does not extend the Command class
15
     */
16
    protected function assertValid(array $commands)
17
    {
18
        parent::assertValid($commands);
19
20
        foreach ($commands as $command) {
21
            if (!is_subclass_of($command, Command::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Symfony\Component\Console\Command\Command::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
22
                throw CommandException::invalidCommand($command);
23
            }
24
        }
25
    }
26
}
27