Passed
Push — main ( 25f4a8...799be8 )
by Sebastian
03:52
created

TestIO::write()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 1
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * This file is part of CaptainHook.
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Console\IO;
13
14
use CaptainHook\App\Console\IO;
15
16
class TestIO implements IO
17
{
18
    private array $log = [];
19
    private array $err = [];
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function getArguments(): array
25
    {
26
        return [];
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32
    public function getArgument(string $name, string $default = ''): string
33
    {
34
        return '';
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function getStandardInput(): array
41
    {
42
        return [];
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    public function isInteractive()
49
    {
50
        return false;
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56
    public function isVerbose()
57
    {
58
        return false;
59
    }
60
61
    /**
62
     * @inheritDoc
63
     */
64
    public function isVeryVerbose()
65
    {
66
        return false;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    public function isDebug()
73
    {
74
        return false;
75
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80
    public function write($messages, $newline = true, $verbosity = self::NORMAL)
81
    {
82
        $this->log[] = (is_array($messages) ? implode(PHP_EOL, $messages) : $messages) . ($newline ? PHP_EOL : '');
83
    }
84
85
    public function getLog(): array
86
    {
87
        return $this->log;
88
    }
89
90
    /**
91
     * @inheritDoc
92
     */
93
    public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
94
    {
95
        $this->err[] = $messages . ($newline ? PHP_EOL : '');
96
    }
97
98
    public function getErr(): array
99
    {
100
        return $this->err;
101
    }
102
103
    /**
104
     * @inheritDoc
105
     */
106
    public function ask($question, $default = null)
107
    {
108
        return '';
109
    }
110
111
    /**
112
     * @inheritDoc
113
     */
114
    public function askConfirmation($question, $default = true)
115
    {
116
        return true;
117
    }
118
119
    /**
120
     * @inheritDoc
121
     */
122
    public function askAndValidate($question, $validator, $attempts = null, $default = null)
123
    {
124
        return '';
125
    }
126
}
127