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

ListFormatter::overrideRestructure()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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