Completed
Branch module_structure (3116d9)
by Pablo
02:56
created

PreCommitExecuteFactory::fromArray()   B

Complexity

Conditions 8
Paths 128

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 7
ccs 10
cts 10
cp 1
cc 8
eloc 11
nc 128
nop 1
crap 8
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use PhpGitHooks\Module\Configuration\Domain\Execute;
6
use PhpGitHooks\Module\Configuration\Model\ExecuteInterface;
7
8
class PreCommitExecuteFactory
9
{
10
    /**
11
     * @param array $data
12
     *
13
     * @return ExecuteInterface
14
     */
15 1
    public static function fromArray(array $data)
16
    {
17
        $tools = [
18 1
            isset($data['composer']) ? ComposerFactory::fromArray($data['composer']) : ComposerFactory::setUndefined(),
19 1
            isset($data['jsonlint']) ? JsonLintFactory::fromArray($data['jsonlint']) : JsonLintFactory::setUndefined(),
20 1
            isset($data['phplint']) ? PhpLintFactory::fromArray($data['phplint']) : PhpLintFactory::setUndefined(),
21 1
            isset($data['phpmd']) ? PhpMdFactory::fromArray($data['phpmd']) : PhpMdFactory::setUndefined(),
22 1
            isset($data['phpcs']) ? PhpCsFactory::fromArray($data['phpcs']) : PhpCsFactory::setUndefined(),
23 1
            isset($data['php-cs-fixer']) ? PhpCsFixerFactory::fromArray($data['php-cs-fixer']) :
24 1
                PhpCsFixerFactory::setUndefined(),
25 1
            isset($data['phpunit']) ? PhpUnitFactory::fromArray($data['phpunit']) : PhpUnitFactory::setUndefined(),
26
        ];
27
28 1
        return new Execute($tools);
29
    }
30
31
    /**
32
     * @return Execute
33
     */
34 3
    public static function setUndefined()
35
    {
36
        $tools = [
37 3
            ComposerFactory::setUndefined(),
38 3
            JsonLintFactory::setUndefined(),
39 3
            PhpLintFactory::setUndefined(),
40 3
            PhpMdFactory::setUndefined(),
41 3
            PhpCsFactory::setUndefined(),
42 3
            PhpCsFixerFactory::setUndefined(),
43 3
            PhpUnitFactory::setUndefined(),
44
        ];
45
46 3
        return new Execute($tools);
47
    }
48
}
49