CustomCommandFacade::getCommands()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexus\CustomCommand\Business;
5
6
use Xervice\Core\Business\Model\Facade\AbstractFacade;
7
8
/**
9
 * @method \Nexus\CustomCommand\Business\CustomCommandBusinessFactory getFactory()
10
 * @method \Nexus\CustomCommand\CustomCommandConfig getConfig()
11
 */
12
class CustomCommandFacade extends AbstractFacade implements CustomCommandFacadeInterface
13
{
14
    /**
15
     * @param array $commands
16
     * @param string $directory
17
     * @param bool $recursive
18
     *
19
     * @return array
20
     */
21 3
    public function hydrateCommands(array $commands, string $directory, bool $recursive): array
22
    {
23 3
        return $this->getFactory()->createCommandHydrator($directory, $recursive)->hydrateCommands($commands);
24
    }
25
26
    /**
27
     * @param string $command
28
     *
29
     * @return string
30
     */
31
    public function runShell(string $command) : string
32
    {
33
        return $this->getFactory()->getShellFacade()->runCommand($command);
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getCommands(): array
40
    {
41
        return $this->hydrateCommands(
42
            [],
43
            $this->getConfig()->getCommandPath(),
44
            true
45
        );
46
    }
47
}