CrudFieldAbstract   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 40
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fieldAttributes() 0 6 1
A wrapperAttributes() 0 6 1
A addWrapperAttribute() 0 10 3
A col() 0 6 1
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