Test Setup Failed
Push — master ( 016bc5...505cdc )
by Alec
02:25
created

EchoOutputAdapter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
eloc 7
c 2
b 0
f 1
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 8 4
A getStream() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Spinner\Core\Adapters;
4
5
use AlecRabbit\Spinner\Core\Contracts\OutputInterface;
6
7
/**
8
 * Class EchoOutputAdapter
9
 *
10
 * @codeCoverageIgnore
11
 */
12
class EchoOutputAdapter implements OutputInterface
13
{
14
    /** {@inheritDoc} */
15
    public function write($messages, $newline = false, $options = 0): void
16
    {
17
        if (!is_iterable($messages)) {
18
            $messages = [$messages];
19
        }
20
        $nl = $newline ? PHP_EOL : '';
21
        foreach ($messages as $message) {
22
            echo $message . $nl;
23
        }
24
    }
25
26
    /**
27
     * @return resource
28
     */
29
    public function getStream()
30
    {
31
        return STDOUT;
32
    }
33
}
34