Completed
Branch master (738bd6)
by Pablo
88:01 queued 83:16
created

ToolHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 0
cbo 1
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setOutput() 0 4 1
A writeOutputError() 0 5 1
1
<?php
2
3
namespace PhpGitHooks\Infrastructure\Common;
4
5
use PhpGitHooks\Command\OutputHandlerInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
/**
9
 * Class ToolHandler.
10
 */
11
abstract class ToolHandler
12
{
13
    /** @var OutputHandlerInterface  */
14
    protected $outputHandler;
15
    /** @var  OutputInterface */
16
    protected $output;
17
18
    /**
19
     * @param OutputHandlerInterface $outputHandler
20
     */
21
    public function __construct(OutputHandlerInterface $outputHandler)
22
    {
23
        $this->outputHandler = $outputHandler;
24
    }
25
26
    /**
27
     * @param OutputInterface $outputInterface
28
     */
29
    public function setOutput(OutputInterface $outputInterface)
30
    {
31
        $this->output = $outputInterface;
32
    }
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
    }
43
}
44