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

AbstractOutputtingSubscriber::setOutput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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