Passed
Push — master ( f4d366...672a66 )
by Thomas
03:42 queued 01:49
created

CrudColumn   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 28
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCrudColumn() 0 12 2
A addCrudColumnOptions() 0 6 2
1
<?php
2
3
namespace Webfactor\Laravel\Generators\Traits;
4
5
trait CrudColumn
6
{
7
    private $column = [];
8
9
    protected $crudColumnType;
10
11
    protected $crudColumnOptions = [];
12
13
    public function getCrudColumn(): array
14
    {
15
        $this->column['name'] = $this->name;
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16
        $this->column['label'] = $this->name;
17
        $this->column['type'] = $this->crudColumnType;
18
19
        if ($this->crudColumnOptions) {
20
            $this->addCrudColumnOptions();
21
        }
22
23
        return $this->column;
24
    }
25
26
    private function addCrudColumnOptions()
27
    {
28
        foreach ($this->crudColumnOptions as $key => $option) {
29
            $this->column[$key] = $option;
30
        }
31
    }
32
}
33