Passed
Push — master ( 9925c8...02f327 )
by Thomas
03:39 queued 01:47
created

CrudFieldAbstract::addWrapperAttribute()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 2
nop 2
crap 12
1
<?php
2
3
namespace Webfactor\Laravel\Backpack\FluentSyntax\Contracts;
4
5
abstract class CrudFieldAbstract extends CrudAbstract implements CrudFieldInterface
6
{
7
    /*
8
    |--------------------------------------------------------------------------
9
    | Methods available for all Field Types
10
    |--------------------------------------------------------------------------
11
    */
12
13
    public function fieldAttributes(array $fieldAttributes)
14
    {
15
        $this->options['attributes'] = $fieldAttributes;
16
17
        return $this;
18
    }
19
20
    public function wrapperAttributes(array $wrapperAttributes)
21
    {
22
        $this->options['wrapperAttributes'] = $wrapperAttributes;
23
24
        return $this;
25
    }
26
27
    public function addWrapperAttribute(string $key, string $value)
28
    {
29
        if ($key == 'class' && isset($this->options['wrapperAttributes']['class'])) {
30
            $this->options['wrapperAttributes']['class'] .= ' ' . $value;
31
        } else {
32
            $this->options['wrapperAttributes'][$key] = $value;
33
        }
34
35
        return $this;
36
    }
37
38
    public function col(string $colWidth)
39
    {
40
        $this->addWrapperAttribute('class', 'form-group col-' . $colWidth);
41
42
        return $this;
43
    }
44
}
45