PropelCommandProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 17
dl 0
loc 66
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
A __construct() 0 5 1
A execute() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Database\Business\Model\Provider;
6
7
8
use Symfony\Component\Process\Process;
9
10
class PropelCommandProvider implements PropelCommandProviderInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    private $propelCommand;
16
17
    /**
18
     * @var string
19
     */
20
    private $rootDirectory;
21
22
    /**
23
     * @var string
24
     */
25
    private $configDir;
26
27
    /**
28
     * @var array
29
     */
30
    private $result;
31
32
    /**
33
     * PropelCommandProvider constructor.
34
     *
35
     * @param string $propelCommand
36
     * @param string $rootDirectory
37
     * @param string $configDir
38
     */
39 2
    public function __construct(string $propelCommand, string $rootDirectory, string $configDir)
40
    {
41 2
        $this->propelCommand = $propelCommand;
42 2
        $this->rootDirectory = $rootDirectory;
43 2
        $this->configDir = $configDir;
44 2
    }
45
46
47
    /**
48
     * @param string $command
49
     *
50
     * @return array
51
     * @throws \Symfony\Component\Process\Exception\LogicException
52
     * @throws \Symfony\Component\Process\Exception\RuntimeException
53
     */
54 2
    public function execute(string $command) : array
55
    {
56 2
        $this->result = [];
57 2
        $process = new Process(
58 2
            $this->propelCommand . ' ' . $command . ' --config-dir=' . $this->configDir,
0 ignored issues
show
Bug introduced by
$this->propelCommand . '...ir=' . $this->configDir of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
            /** @scrutinizer ignore-type */ $this->propelCommand . ' ' . $command . ' --config-dir=' . $this->configDir,
Loading history...
59 2
            $this->rootDirectory
60
        );
61
62 2
        $process->run([$this, 'handle']);
63
64 2
        return $this->result;
65
    }
66
67
    /**
68
     * @param mixed $type
69
     * @param mixed $buffer
70
     */
71 2
    public function handle($type, $buffer): void
72
    {
73 2
        $this->result[] = [
74 2
            'type' => $type,
75 2
            'buffer' => $buffer
76
        ];
77 2
    }
78
}
79