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

AbstractOutputtingSubscriber::getOutput()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 0
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