Completed
Push — master ( bafc2b...789f6f )
by Oscar
03:26
created

Info   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 52.94 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 5
dl 18
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A defaultRender() 18 18 2

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
3
namespace Folk\Formats;
4
5
use FormManager\Fields;
6
use FormManager\Elements;
7
8
class Info extends Fields\Field implements FormatInterface
9
{
10
    use Traits\HtmlValueTrait;
11
12
    public function __construct()
13
    {
14
        parent::__construct((new Elements\Input())->type('hidden'));
15
16
        $this->set('list', true);
0 ignored issues
show
Documentation Bug introduced by
The method set does not exist on object<Folk\Formats\Info>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
17
        $this->wrapper->class('format is-responsive');
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23 View Code Duplication
    protected function defaultRender($prepend = '', $append = '')
0 ignored issues
show
Duplication introduced by
This method 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...
24
    {
25
        if ($this->error()) {
26
            $this->wrapper->addClass('has-error');
27
        }
28
29
        return <<<EOT
30
{$this->label}
31
32
<div>
33
    {$this->errorLabel}
34
    {$prepend}
35
    <p>{$this->input->val()}</p>
36
    {$this->input}
37
    {$append}
38
</div>
39
EOT;
40
    }
41
}
42