DualOutput::setFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
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