File tree Expand file tree Collapse file tree 6 files changed +42
-11
lines changed
Expand file tree Collapse file tree 6 files changed +42
-11
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public function config(array $data)
5252 private function configMessages ()
5353 {
5454 if (!isset ($ this ->configData [self ::TOOL ])) {
55- $ this ->configData = null ;
55+ $ this ->configData = [] ;
5656 $ rightMessage = $ this ->setMessage (
5757 sprintf ('Write a right message for %s hook: ' , $ this ->hook ),
5858 self ::DEFAULT_RIGHT_MESSAGE
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace PhpGitHooks \Infrastructure \Common ;
4+
5+ use PhpGitHooks \Command \BadJobLogo ;
6+
7+ class ErrorOutput
8+ {
9+ /**
10+ * @param $errorText
11+ *
12+ * @return string
13+ */
14+ public static function write ($ errorText )
15+ {
16+ return BadJobLogo::paint ($ errorText );
17+ }
18+ }
Original file line number Diff line number Diff line change @@ -30,4 +30,14 @@ public function setOutput(OutputInterface $outputInterface)
3030 {
3131 $ this ->output = $ outputInterface ;
3232 }
33+
34+ /**
35+ * @param \Exception $exceptionClass
36+ * @param string $errorText
37+ */
38+ protected function writeOutputError (\Exception $ exceptionClass , $ errorText )
39+ {
40+ ErrorOutput::write ($ errorText );
41+ throw new $ exceptionClass ();
42+ }
3343}
Original file line number Diff line number Diff line change 33namespace PhpGitHooks \Infrastructure \JsonLint ;
44
55use PhpGitHooks \Application \Message \MessageConfigData ;
6- use PhpGitHooks \Command \BadJobLogo ;
76use PhpGitHooks \Infrastructure \Common \RecursiveToolInterface ;
87use PhpGitHooks \Infrastructure \Common \ToolHandler ;
98use Symfony \Component \Process \ProcessBuilder ;
109
1110final class JsonLintHandler extends ToolHandler implements RecursiveToolInterface
1211{
13- /** @var array */
12+ /** @var array */
1413 private $ files = [];
1514 /** @var string */
1615 private $ needle ;
@@ -52,8 +51,10 @@ public function run(array $messages)
5251 });
5352
5453 if ($ errors ) {
55- $ this ->output ->writeln (BadJobLogo::paint ($ messages [MessageConfigData::KEY_ERROR_MESSAGE ]));
56- throw new JsonLintViolationsException (implode ('' , $ errors ));
54+ $ this ->writeOutputError (
55+ new JsonLintViolationsException (implode ('' , $ errors )),
56+ $ messages [MessageConfigData::KEY_ERROR_MESSAGE ]
57+ );
5758 }
5859
5960 $ this ->output ->writeln ($ this ->outputHandler ->getSuccessfulStepMessage ());
Original file line number Diff line number Diff line change 33namespace PhpGitHooks \Infrastructure \PhpCsFixer ;
44
55use PhpGitHooks \Application \Message \MessageConfigData ;
6- use PhpGitHooks \Command \BadJobLogo ;
76use PhpGitHooks \Infrastructure \Common \InteractiveToolInterface ;
87use PhpGitHooks \Infrastructure \Common \ToolHandler ;
98use Symfony \Component \Process \ProcessBuilder ;
@@ -56,8 +55,10 @@ public function run(array $messages)
5655 }
5756
5857 if ($ errors ) {
59- $ this ->output ->writeln (BadJobLogo::paint ($ messages [MessageConfigData::KEY_ERROR_MESSAGE ]));
60- throw new PhpCsFixerException (implode ('' , $ errors ));
58+ $ this ->writeOutputError (
59+ new PhpCsFixerException (implode ('' , $ errors )),
60+ $ messages [MessageConfigData::KEY_ERROR_MESSAGE ]
61+ );
6162 }
6263
6364 $ this ->output ->writeln ($ this ->outputHandler ->getSuccessfulStepMessage ());
Original file line number Diff line number Diff line change 33namespace PhpGitHooks \Infrastructure \PhpMD ;
44
55use PhpGitHooks \Application \Message \MessageConfigData ;
6- use PhpGitHooks \Command \BadJobLogo ;
76use PhpGitHooks \Infrastructure \Common \RecursiveToolInterface ;
87use PhpGitHooks \Infrastructure \Common \ToolHandler ;
98use Symfony \Component \Process \ProcessBuilder ;
@@ -59,8 +58,10 @@ public function run(array $messages)
5958 });
6059
6160 if ($ errors ) {
62- $ this ->output ->writeln (BadJobLogo::paint (MessageConfigData::KEY_ERROR_MESSAGE ));
63- throw new PHPMDViolationsException (implode ('' , $ errors ));
61+ $ this ->writeOutputError (
62+ new PHPMDViolationsException (implode ('' , $ errors )),
63+ MessageConfigData::KEY_ERROR_MESSAGE
64+ );
6465 }
6566
6667 $ this ->output ->writeln ($ this ->outputHandler ->getSuccessfulStepMessage ());
You can’t perform that action at this time.
0 commit comments