UnstructuredListData   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 15
loc 15
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A restructure() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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