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

ListFormatter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 3
c 2
b 0
f 2
lcom 0
cbo 2
dl 0
loc 23
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 4 1
A overrideRestructure() 0 9 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