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

ConfigurationArrayTransformer   B

Complexity

Total Complexity 1

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 16

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 16
dl 0
loc 78
rs 8.4614
ccs 36
cts 36
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 69 1
1
<?php
2
3
namespace PhpGitHooks\Module\Configuration\Service;
4
5
use PhpGitHooks\Module\Configuration\Domain\CommitMsg;
6
use PhpGitHooks\Module\Configuration\Domain\PhpCs;
7
use PhpGitHooks\Module\Configuration\Domain\PhpCsFixer;
8
use PhpGitHooks\Module\Configuration\Domain\PhpUnit;
9
use PhpGitHooks\Module\Configuration\Domain\PreCommit;
10
use PhpGitHooks\Module\Configuration\Domain\PrePush;
11
12
class ConfigurationArrayTransformer
13
{
14
    /**
15
     * @param PreCommit $preCommit
16
     * @param CommitMsg $commitMsg
17
     * @param PrePush $prePush
18
     * @return array
19
     */
20 2
    public static function transform(PreCommit $preCommit, CommitMsg $commitMsg, PrePush $prePush)
21
    {
22 2
        $tools = $preCommit->getExecute()->execute();
23 2
        $prePushTools = $prePush->getExecute()->execute();
24 2
        $composer = $tools[0];
25 2
        $jsonLint = $tools[1];
26 2
        $phpLint = $tools[2];
27 2
        $phpMd = $tools[3];
28
        /** @var PhpCs $phpCs */
29 2
        $phpCs = $tools[4];
30
        /** @var PhpCsFixer $phpCsFixer */
31 2
        $phpCsFixer = $tools[5];
32
        /** @var PhpUnit $phpunit */
33 2
        $phpunit = $tools[6];
34
        /** @var PhpUnit $phpunitPrePush */
35 2
        $phpunitPrePush = $prePushTools[0];
36
37
        return [
38
            'pre-commit' => [
39 2
                'enabled' => $preCommit->isEnabled(),
40
                'process' => [
41 2
                    'composer' => $composer->isEnabled(),
42 2
                    'jsonlint' => $jsonLint->isEnabled(),
43 2
                    'phplint' => $phpLint->isEnabled(),
44 2
                    'phpmd' => $phpMd->isEnabled(),
45
                    'phpcs' => [
46 2
                        'enabled' => $phpCs->isEnabled(),
47 2
                        'standard' => $phpCs->getStandard()->value(),
48
                    ],
49
                    'php-cs-fixer' => [
50 2
                        'enabled' => $phpCsFixer->isEnabled(),
51
                        'levels' => [
52 2
                            'psr0' => $phpCsFixer->getLevels()->getPsr0()->value(),
53 2
                            'psr1' => $phpCsFixer->getLevels()->getPsr1()->value(),
54 2
                            'psr2' => $phpCsFixer->getLevels()->getPsr2()->value(),
55 2
                            'symfony' => $phpCsFixer->getLevels()->getSymfony()->value(),
56
                        ],
57
                    ],
58
                    'phpunit' => [
59 2
                        'enabled' => $phpunit->isEnabled(),
60 2
                        'random-mode' => $phpunit->getRandomMode()->value(),
61 2
                        'options' => $phpunit->getOptions()->value(),
62
                    ],
63
                ],
64
                'messages' => [
65 2
                    'right-message' => $preCommit->getMessages()->getRightMessage()->value(),
66 2
                    'error-message' => $preCommit->getMessages()->getErrorMessage()->value(),
67
                ],
68
            ],
69
            'commit-msg' => [
70 2
                'enabled' => $commitMsg->isEnabled(),
71 2
                'regular-expression' => $commitMsg->getRegularExpression()->value(),
72
            ],
73
            'pre-push' => [
74 2
                'enabled' => $prePush->isEnabled(),
75
                'process' => [
76
                    'phpunit' => [
77 2
                        'enabled' => $phpunitPrePush->isEnabled(),
78 2
                        'random-mode' => $phpunitPrePush->getRandomMode()->value(),
79 2
                        'options' => $phpunitPrePush->getOptions()->value()
80
                    ]
81
                ],
82
                'messages' => [
83 2
                    'right-message' => $prePush->getMessages()->getRightMessage()->value(),
84 2
                    'error-message' => $prePush->getMessages()->getErrorMessage()->value()
85
                ]
86
            ]
87
        ];
88
    }
89
}
90