1 | <?php |
||
14 | class ConfigurationProcessor |
||
15 | { |
||
16 | /** |
||
17 | * @var IOInterface |
||
18 | */ |
||
19 | private $io; |
||
20 | /** |
||
21 | * @var PreCommitProcessor |
||
22 | */ |
||
23 | private $preCommitProcessor; |
||
24 | /** |
||
25 | * @var CommitMsgProcessor |
||
26 | */ |
||
27 | private $commitMsgProcessor; |
||
28 | /** |
||
29 | * @var ConfigurationFileWriterInterface |
||
30 | */ |
||
31 | private $configurationFileWriter; |
||
32 | /** |
||
33 | * @var HookCopier |
||
34 | */ |
||
35 | private $hookCopier; |
||
36 | /** |
||
37 | * @var ConfigurationFileReaderInterface |
||
38 | */ |
||
39 | private $configurationFileReader; |
||
40 | /** |
||
41 | * @var PrePushProcessor |
||
42 | */ |
||
43 | private $prePushProcessor; |
||
44 | |||
45 | /** |
||
46 | * ConfigurationProcessor constructor. |
||
47 | * |
||
48 | * @param ConfigurationFileReaderInterface $configurationFileReader |
||
49 | * @param PreCommitProcessor $preCommitProcessor |
||
50 | * @param CommitMsgProcessor $commitMsgProcessor |
||
51 | * @param ConfigurationFileWriterInterface $configurationFileWriter |
||
52 | * @param HookCopier $hookCopier |
||
53 | * @param PrePushProcessor $prePushProcessor |
||
54 | */ |
||
55 | 2 | public function __construct( |
|
70 | |||
71 | /** |
||
72 | * @param IOInterface $input |
||
73 | */ |
||
74 | 1 | public function process(IOInterface $input) |
|
75 | { |
||
76 | 1 | $this->io = $input; |
|
77 | |||
78 | 1 | $configData = $this->configurationFileReader->getData(); |
|
79 | 1 | $preCommit = $this->preCommitProcess($configData); |
|
80 | |||
81 | 1 | if (true === $preCommit->isEnabled()) { |
|
82 | 1 | $this->hookCopier->copyPreCommitHook(); |
|
83 | 1 | } |
|
84 | |||
85 | 1 | $commitMsg = $this->commitMsgProcess($configData); |
|
86 | |||
87 | 1 | if (true === $commitMsg->isEnabled()) { |
|
88 | 1 | $this->hookCopier->copyCommitMsgHook(); |
|
89 | 1 | } |
|
90 | |||
91 | 1 | $prePush = $this->prePushProcess($configData); |
|
92 | |||
93 | 1 | if (true === $prePush->isEnabled()) { |
|
94 | 1 | $this->hookCopier->copyPrePushHook(); |
|
95 | 1 | } |
|
96 | |||
97 | 1 | $configArray = ConfigurationArrayTransformer::transform($preCommit, $commitMsg, $prePush); |
|
98 | |||
99 | 1 | $this->configurationFileWriter->write($configArray); |
|
100 | } |
||
101 | |||
102 | /** |
||
103 | * @param Config $configData |
||
104 | * |
||
105 | * @return PreCommit |
||
106 | */ |
||
107 | 1 | private function preCommitProcess(Config $configData) |
|
114 | |||
115 | /** |
||
116 | * @param Config $configData |
||
117 | * |
||
118 | * @return CommitMsg |
||
119 | */ |
||
120 | 1 | private function commitMsgProcess(Config $configData) |
|
127 | |||
128 | /** |
||
129 | * @param Config $configData |
||
130 | * |
||
131 | * @return PrePush |
||
132 | */ |
||
133 | 1 | private function prePushProcess(Config $configData) |
|
140 | } |
||
141 |