Completed
Push — master ( d4953c...26fc7b )
by personal
04:50
created

CliOutput::clearln()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
3
/*
4
 * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Hal\Component\Output;
11
12
/**
13
 * Class CliOutput
14
 * @package Hal\Component\Issue
15
 */
16
class CliOutput implements Output
17
{
18
    /**
19
     * @var bool
20
     */
21
    private $quietMode = false;
22
23
    /**
24
     * @inheritdoc
25
     */
26
    public function writeln($message)
27
    {
28
        $this->write(PHP_EOL . $message);
29
        return $this;
30
    }
31
32
    /**
33
     * @inheritdoc
34
     */
35
    public function write($message)
36
    {
37
        $this->quietMode||file_put_contents('php://stdout', $message);
38
        return $this;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function err($message)
45
    {
46
        file_put_contents('php://stderr', $message);
47
        return $this;
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function clearln()
54
    {
55
        $this->writeln("\x0D");
56
        $this->writeln("\x1B[2K");
57
        return $this;
58
    }
59
60
    /**
61
     * @param boolean $quietMode
62
     * @return $this
63
     */
64
    public function setQuietMode($quietMode)
65
    {
66
        $this->quietMode = $quietMode;
67
        return $this;
68
    }
69
}
70
71