Passed
Branch master (03c1d9)
by Greg
02:52
created

ListFormatter::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
namespace Consolidation\OutputFormatters\Formatters;
3
4
use Symfony\Component\Console\Output\OutputInterface;
5
use Consolidation\OutputFormatters\FormatterInterface;
6
use Consolidation\OutputFormatters\OverrideRestructureInterface;
7
use Consolidation\OutputFormatters\StructuredData\ListDataInterface;
8
9
class ListFormatter implements FormatterInterface, OverrideRestructureInterface
10
{
11
    /**
12
     * @inheritdoc
13
     */
14 3
    public function write(OutputInterface $output, $data, $options = [])
15
    {
16 3
        $output->writeln(implode("\n", $data));
17 3
    }
18
19
    /**
20
     * @inheritdoc
21
     */
22 3
    public function overrideRestructure($structuredOutput, $configurationData, $options)
23
    {
24
        // If the structured data implements ListDataInterface,
25
        // then we will render whatever data its 'getListData'
26
        // method provides.
27 3
        if ($structuredOutput instanceof ListDataInterface) {
28 2
            return $structuredOutput->getListData();
29
        }
30 1
    }
31
}
32