Passed
Push — master ( 3376db...1497f5 )
by Mike
12:25
created

CustomCommandFacade::getCommands()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
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
3
4
namespace Nexus\CustomCommand;
5
6
7
use Xervice\Core\Facade\AbstractFacade;
8
9
/**
10
 * @method \Nexus\CustomCommand\CustomCommandFactory getFactory()
11
 * @method \Nexus\CustomCommand\CustomCommandConfig getConfig()
12
 * @method \Nexus\CustomCommand\CustomCommandClient getClient()
13
 */
14
class CustomCommandFacade extends AbstractFacade
15
{
16
    /**
17
     * @param array $commands
18
     * @param string $directory
19
     * @param bool $recursive
20
     *
21
     * @return array
22
     */
23 3
    public function hydrateCommands(array $commands, string $directory, bool $recursive)
24
    {
25 3
        return $this->getFactory()->createCommandHydrator($directory, $recursive)->hydrateCommands($commands);
26
    }
27
28
    /**
29
     * @param string $command
30
     *
31
     * @return string
32
     */
33
    public function runShell(string $command) : string
34
    {
35
        return $this->getFactory()->getShellFacade()->runCommand($command);
36
    }
37
38
    /**
39
     * @return array
40
     * @throws \Xervice\Config\Exception\ConfigNotFound
41
     */
42
    public function getCommands()
43
    {
44
        return $this->hydrateCommands(
45
            [],
46
            $this->getConfig()->getCommandPath(),
47
            true
48
        );
49
    }
50
}