Element::getAttributes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
}