DualOutput   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 9
c 2
b 1
f 0
dl 0
loc 44
ccs 0
cts 14
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setConsoleOutput() 0 5 1
A setFile() 0 5 1
A doWrite() 0 5 1
1
<?php
2
3
namespace Tequilarapido\Consolify\Output;
4
5
use Symfony\Component\Console\Output\StreamOutput;
6
use Symfony\Component\Console\Output\ConsoleOutput;
7
8
class DualOutput extends StreamOutput
9
{
10
    /** @var string */
11
    protected $file;
12
13
    /** @var ConsoleOutput */
14
    protected $consoleOuput;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    protected function doWrite($message, $newline)
20
    {
21
        parent::doWrite($message, $newline);
22
23
        $this->consoleOuput->write($message, $newline, true);
24
    }
25
26
    /**
27
     * Set console output from artisan console command.
28
     *
29
     * @param $consoleOutput
30
     *
31
     * @return $this
32
     */
33
    public function setConsoleOutput($consoleOutput)
34
    {
35
        $this->consoleOuput = $consoleOutput;
36
37
        return $this;
38
    }
39
40
    /**
41
     * Set the path to the file where the console output will be streamed.
42
     *
43
     * @param $file
44
     *
45
     * @return $this
46
     */
47
    public function setFile($file)
48
    {
49
        $this->file = $file;
50
51
        return $this;
52
    }
53
}
54