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

Info::customRender()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 2
eloc 11
nc 2
nop 2
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