Completed
Pull Request — master (#66)
by Greg
01:50
created

RowsOfFieldsWithMetadata   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __constructor() 0 4 1
A restructure() 0 8 1
A getMetadata() 0 4 1
1
<?php
2
namespace Consolidation\OutputFormatters\StructuredData;
3
4
use Consolidation\OutputFormatters\Options\FormatterOptions;
5
6
/**
7
 * A RowsOfFields data structure that also contains metadata.
8
 * @see MetadataHolderTrait
9
 */
10
class RowsOfFieldsWithMetadata extends RowsOfFields implements MetadataInterface, MetadataHolderInterface
11
{
12
    use MetadataHolderTrait;
13
14
    public function __constructor($data)
15
    {
16
        parent::__construct($data);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (__construct() instead of __constructor()). Are you sure this is correct? If so, you might want to change this to $this->__construct().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
17
    }
18
19
    /**
20
     * Restructure this data for output by converting it into a table
21
     * transformation object. First, though, remove any metadata items.
22
     *
23
     * @param FormatterOptions $options Options that affect output formatting.
24
     * @return Consolidation\OutputFormatters\Transformations\TableTransformation
25
     */
26
    public function restructure(FormatterOptions $options)
27
    {
28
        $originalData = $this->getArrayCopy();
29
        $data = $this->extractData($originalData);
30
        $tableTranformer = $this->createTableTransformation($data, $options);
31
        $tableTranformer->setOriginalData($this);
32
        return $tableTranformer;
33
    }
34
35
    public function getMetadata()
36
    {
37
        return $this->extractMetadata($this->getArrayCopy());
38
    }
39
}
40