Completed
Push — master ( 30460b...74da27 )
by wen
03:07
created

Column::__construct()   A

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 1
1
<?php
2
3
4
namespace Sco\Admin\Column;
5
6
use Sco\Attributes\HasOriginalAndAttributesTrait;
7
8
abstract class Column
9
{
10
    use HasOriginalAndAttributesTrait;
11
12
    protected $defaultsOptions = [
13
        'key'      => '',
14
        'title'    => '',
15
        'sortable' => true,
16
        'width'    => 0,
17
    ];
18
19
    protected $defaults = [];
20
21
    public function __construct($options)
22
    {
23
        $this->setOriginal(array_merge($this->getDefaults(), $options));
24
    }
25
26
    protected function getDefaults()
27
    {
28
        return array_merge($this->defaultsOptions, $this->defaults);
29
    }
30
31
    function __toString()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
32
    {
33
        return $this->toJson();
34
    }
35
}
36