Element   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributes() 0 4 1
A attributesToHtml() 0 21 3
1
<?php
2
3
namespace App\Administrator\Types;
4
5
use Keyhunter\Administrator\Form\Element as BaseElement;
6
7
abstract class Element extends BaseElement
8
{
9
    public function getAttributes()
10
    {
11
        return $this->attributes;
12
    }
13
14
    public function attributesToHtml($attributes = null)
15
    {
16
        if(! $attributes)
17
            $attributes = $this->getAttributes();
18
19
        $html = '';
20
        $i = 1;
21
        array_walk($attributes, function ($attr, $k) use (&$html, &$i, $attributes){
22
            $template = sprintf("%s=\"%s\"", $k, $attr);
23
24
            if($i == 1){
25
                $html .= $template;
26
            }else{
27
                $html .= " " . $template;
28
            }
29
30
            $i++;
31
        });
32
33
        return $html;
34
    }
35
}