fieldsetGenerator   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 31
c 1
b 0
f 0
dl 0
loc 66
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Open() 0 16 3
A Close() 0 6 2
A __construct() 0 13 4
A Attributes() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: sjhc1170
5
 * Date: 16/05/2018
6
 * Time: 15:10
7
 */
8
9
namespace Iriven\Plugins\Form\Core;
10
11
12
use \Iriven\Plugins\Form\Core\Libs\AttributesBuilder;
0 ignored issues
show
Bug introduced by
The type \Iriven\Plugins\Form\Core\Libs\AttributesBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class fieldsetGenerator
15
{
16
    private $attributes;
17
    private $legend;
18
    private $legendAttributes;
19
    private $isOpened = false;
20
21
    /**
22
     * fieldsetGenerator constructor.
23
     *
24
     * @param $attributes
25
     */
26
    public function __construct($attributes)
27
    {
28
        if(!$attributes instanceof AttributesBuilder)
29
            $attributes  = new AttributesBuilder($attributes);
30
        $this->attributes = $attributes;
31
        if($this->attributes->has('legend'))
32
        {
33
            $this->attributes->Ignore('legend');
34
            $this->legend = $this->attributes->get('legend');
35
            if($this->attributes->has('legend-attributes'))
36
            {
37
                $this->attributes->Ignore('legend-attributes');
38
                $this->legendAttributes = new AttributesBuilder($this->attributes->get('legend-attributes'));
39
            }
40
        }
41
    }
42
43
    /**
44
     * @return AttributesBuilder
45
     */
46
    public function Attributes()
47
    {
48
        return $this->attributes;
49
    }
50
    /**
51
     * @return string
52
     */
53
    public function Open()
54
    {
55
        $html  = '<fieldset';
56
        $html .= $this->attributes->RenderHtml();
57
        $html .= '>';
58
        if($this->legend)
59
        {
60
            $html .= '<legend';
61
            if($this->legendAttributes instanceof AttributesBuilder)
62
            $html .= $this->legendAttributes->RenderHtml();
63
            $html .= '>';
64
            $html .= $this->legend;
65
            $html .= '</legend>';
66
        }
67
        $this->isOpened = true;
68
        return $html;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function Close()
75
    {
76
        $html  = '';
77
        if($this->isOpened)
78
            $html .= '</fieldset>';
79
        return $html;
80
    }
81
82
}