Passed
Push — master ( 3d4557...4c2a8d )
by Hannes
01:54
created

AbstractOutputtingSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
c 0
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setOutput() 0 3 1
A getOutput() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace hanneskod\readmetester\Output;
6
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
abstract class AbstractOutputtingSubscriber
10
{
11
    private ?OutputInterface $output;
12
13
    public function getOutput(): OutputInterface
14
    {
15
        if (!isset($this->output)) {
16
            throw new \LogicException('Unable to get output, did you call setOutput()?');
17
        }
18
19
        return $this->output;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->output could return the type null which is incompatible with the type-hinted return Symfony\Component\Console\Output\OutputInterface. Consider adding an additional type-check to rule them out.
Loading history...
20
    }
21
22
    public function setOutput(OutputInterface $output): void
23
    {
24
        $this->output = $output;
25
    }
26
}
27