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

Collection::customRender()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 21
rs 9.3142
cc 3
eloc 13
nc 4
nop 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A Collection::html() 0 18 3
1
<?php
2
3
namespace Folk\Formats;
4
5
use FormManager\Fields;
6
use FormManager\Builder;
7
8
class Collection extends Fields\Collection implements FormatInterface
9
{
10
    use Traits\LabelTrait;
11
    use Traits\ToolbarTrait;
12
    use Traits\CollectionValueTrait;
13
    use Traits\RenderContainerTrait;
14
15 View Code Duplication
    public function __construct(Builder $builder, array $children = null)
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...
16
    {
17
        parent::__construct($children);
18
19
        $this->set('list', false);
20
        $this->class('format is-collection is-responsive is-large');
0 ignored issues
show
Documentation Bug introduced by
The method class does not exist on object<Folk\Formats\Collection>? 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...
21
        $this->data('module', 'format-collection');
22
    }
23
24
    public function html($html = null)
25
    {
26
        if ($html !== null) {
27
            return parent::html($html);
28
        }
29
30
        $addBtn = '<div class="button-separator"><button type="button" class="format-child-add button">Add</button></div>';
31
        $toolbar = '<div class="button-toolbar"><strong class="button-toolbar-label"></strong>'.$this->getToolbarButtons().'</div>';
32
        $html = '<script type="js-template">'.$this->getTemplate()->toHtml($addBtn.$toolbar).'</script>';
33
34
        foreach ($this as $child) {
35
            $html .= $child->toHtml($addBtn.$toolbar);
36
        }
37
38
        $html .= "<div>{$addBtn}</div>";
39
40
        return $html;
41
    }
42
}
43