UnstructuredListData::restructure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace Consolidation\OutputFormatters\StructuredData;
3
4
use Consolidation\OutputFormatters\Options\FormatterOptions;
5
use Consolidation\OutputFormatters\StructuredData\RestructureInterface;
6
use Consolidation\OutputFormatters\Transformations\UnstructuredDataListTransformation;
7
8
/**
9
 * Represents aribtrary unstructured array data where the
10
 * data to display in --list format comes from the array keys.
11
 *
12
 * Unstructured list data can have variable keys in every rown (unlike
13
 * RowsOfFields, which expects uniform rows), and the data elements may
14
 * themselves be deep arrays.
15
 */
16 View Code Duplication
class UnstructuredListData extends AbstractListData implements UnstructuredInterface, RestructureInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    public function __construct($data)
19
    {
20
        parent::__construct($data);
21
    }
22
23
    public function restructure(FormatterOptions $options)
24
    {
25
        $defaults = $this->defaultOptions();
26
        $fields = $this->getFields($options, $defaults);
27
28
        return new UnstructuredDataListTransformation($this->getArrayCopy(), FieldProcessor::processFieldAliases($fields));
29
    }
30
}
31