Handler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 45
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A handle() 0 6 1
A setOutput() 0 6 1
A getWriter() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of Collision.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace NunoMaduro\Collision;
13
14
use NunoMaduro\Collision\Contracts\Handler as HandlerContract;
15
use NunoMaduro\Collision\Contracts\Writer as WriterContract;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Whoops\Handler\Handler as AbstractHandler;
18
19
/**
20
 * This is an Collision Handler implementation.
21
 *
22
 * @author Nuno Maduro <[email protected]>
23
 */
24
class Handler extends AbstractHandler implements HandlerContract
25
{
26
    /**
27
     * Holds an instance of the writer.
28
     *
29
     * @var \NunoMaduro\Collision\Contracts\Writer
30
     */
31
    protected $writer;
32
33
    /**
34
     * Creates an instance of the Handler.
35
     */
36 7
    public function __construct(WriterContract $writer = null)
37
    {
38 7
        $this->writer = $writer ?: new Writer();
39 7
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function handle()
45
    {
46 1
        $this->writer->write($this->getInspector());
47
48 1
        return static::QUIT;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54 1
    public function setOutput(OutputInterface $output): HandlerContract
55
    {
56 1
        $this->writer->setOutput($output);
57
58 1
        return $this;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64 1
    public function getWriter(): WriterContract
65
    {
66 1
        return $this->writer;
67
    }
68
}
69