Passed
Push — master ( 3109ad...89528c )
by Peter
02:44
created

Base   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 58
c 1
b 0
f 0
dl 0
loc 102
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getOptions() 0 15 2
A getWrapperTags() 0 24 2
A getWrapperClasses() 0 24 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Website\Template\Builder\ContentList;
6
7
use AbterPhp\Framework\Constant\Html5;
8
use AbterPhp\Framework\Template\IBuilder;
9
use AbterPhp\Framework\Template\ParsedTemplate;
10
11
class Base
12
{
13
    protected $defaultListTag    = Html5::TAG_UL;
14
    protected $defaultItemTag    = Html5::TAG_LI;
15
    protected $defaultLabelTag   = '';
16
    protected $defaultContentTag = '';
17
    protected $defaultImageTag   = '';
18
19
    protected $defaultListClass    = 'list-unknown';
20
    protected $defaultItemClass    = 'list-item';
21
    protected $defaultLabelClass   = 'list-item-label';
22
    protected $defaultContentClass = 'list-item-content';
23
    protected $defaultImageClass   = 'list-item-image';
24
25
    protected $defaultWithLabel = '0';
26
    protected $defaultWithImage = '0';
27
28
    /**
29
     * @param ParsedTemplate|null $template
30
     *
31
     * @return <string,string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment <string,string> at position 0 could not be parsed: Unknown type name '<' at position 0 in <string,string>.
Loading history...
32
     */
33
    protected function getWrapperTags(?ParsedTemplate $template = null): array
34
    {
35
        if (!$template) {
36
            return [
37
                IBuilder::LIST_TAG    => $this->defaultListTag,
38
                IBuilder::ITEM_TAG    => $this->defaultItemTag,
39
                IBuilder::LABEL_TAG   => $this->defaultLabelTag,
40
                IBuilder::CONTENT_TAG => $this->defaultContentTag,
41
                IBuilder::IMAGE_TAG   => $this->defaultImageTag,
42
            ];
43
        }
44
45
        $listTag    = $template->getAttribute(static::LIST_TAG, $this->defaultListTag);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...tentList\Base::LIST_TAG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
46
        $itemTag    = $template->getAttribute(static::ITEM_TAG, $this->defaultItemTag);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...tentList\Base::ITEM_TAG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
47
        $labelTag   = $template->getAttribute(static::LABEL_TAG, $this->defaultLabelTag);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...entList\Base::LABEL_TAG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
48
        $contentTag = $template->getAttribute(static::CONTENT_TAG, $this->defaultContentTag);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...tList\Base::CONTENT_TAG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
49
        $imageTag   = $template->getAttribute(static::IMAGE_TAG, $this->defaultImageTag);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...entList\Base::IMAGE_TAG was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
51
        return [
52
            IBuilder::LIST_TAG    => $listTag,
53
            IBuilder::ITEM_TAG    => $itemTag,
54
            IBuilder::LABEL_TAG   => $labelTag,
55
            IBuilder::CONTENT_TAG => $contentTag,
56
            IBuilder::IMAGE_TAG   => $imageTag,
57
        ];
58
    }
59
60
    /**
61
     * @param ParsedTemplate|null $template
62
     *
63
     * @return <string,string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment <string,string> at position 0 could not be parsed: Unknown type name '<' at position 0 in <string,string>.
Loading history...
64
     */
65
    protected function getWrapperClasses(?ParsedTemplate $template = null): array
66
    {
67
        if (!$template) {
68
            return [
69
                IBuilder::LIST_CLASS    => $this->defaultListClass,
70
                IBuilder::ITEM_CLASS    => $this->defaultItemClass,
71
                IBuilder::LABEL_CLASS   => $this->defaultLabelClass,
72
                IBuilder::CONTENT_CLASS => $this->defaultContentClass,
73
                IBuilder::IMAGE_CLASS   => $this->defaultImageClass,
74
            ];
75
        }
76
77
        $listClass    = $template->getAttribute(static::LIST_CLASS, $this->defaultListClass);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...ntList\Base::LIST_CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
78
        $itemClass    = $template->getAttribute(static::ITEM_CLASS, $this->defaultItemClass);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...ntList\Base::ITEM_CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
79
        $labelClass   = $template->getAttribute(static::LABEL_CLASS, $this->defaultLabelClass);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...tList\Base::LABEL_CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
80
        $contentClass = $template->getAttribute(static::CONTENT_CLASS, $this->defaultContentClass);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...ist\Base::CONTENT_CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
81
        $imageClass   = $template->getAttribute(static::IMAGE_CLASS, $this->defaultImageClass);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...tList\Base::IMAGE_CLASS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
82
83
        return [
84
            IBuilder::LIST_CLASS    => $listClass,
85
            IBuilder::ITEM_CLASS    => $itemClass,
86
            IBuilder::LABEL_CLASS   => $labelClass,
87
            IBuilder::CONTENT_CLASS => $contentClass,
88
            IBuilder::IMAGE_CLASS   => $imageClass,
89
        ];
90
    }
91
92
93
    /**
94
     * @param ParsedTemplate|null $template
95
     *
96
     * @return <string,string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment <string,string> at position 0 could not be parsed: Unknown type name '<' at position 0 in <string,string>.
Loading history...
97
     */
98
    protected function getOptions(?ParsedTemplate $template = null): array
99
    {
100
        if (!$template) {
101
            return [
102
                IBuilder::WITH_LABEL_OPTION => (bool)$this->defaultWithLabel,
103
                IBuilder::WITH_IMAGE_OPTION => (bool)$this->defaultWithImage,
104
            ];
105
        }
106
107
        $listClass = $template->getAttribute(static::WITH_LABEL_OPTION, $this->defaultWithLabel);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...Base::WITH_LABEL_OPTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
108
        $itemClass = $template->getAttribute(static::WITH_IMAGE_OPTION, $this->defaultWithImage);
0 ignored issues
show
Bug introduced by
The constant AbterPhp\Website\Templat...Base::WITH_IMAGE_OPTION was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
109
110
        return [
111
            IBuilder::WITH_LABEL_OPTION => (bool)$listClass,
112
            IBuilder::WITH_IMAGE_OPTION => (bool)$itemClass,
113
        ];
114
    }
115
}
116