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

CrudColumn::getCrudColumn()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
crap 6
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