Completed
Push — master ( dc232d...5ccba3 )
by Song
02:47 queued 15s
created

Column::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2019. Mallto.Co.Ltd.<mall-to.com> All rights reserved.
4
 */
5
6
namespace Encore\Admin\Form\Layout;
7
8
use Encore\Admin\Form\Field;
9
use Illuminate\Support\Collection;
10
11
class Column
12
{
13
    /**
14
     * @var Collection
15
     */
16
    protected $fields;
17
18
    /**
19
     * @var int
20
     */
21
    protected $width;
22
23
    /**
24
     * Column constructor.
25
     *
26
     * @param int $width
27
     */
28
    public function __construct($width = 12)
29
    {
30
        $this->width = $width;
31
        $this->fields = new Collection();
32
    }
33
34
    /**
35
     * Add a filter to this column.
36
     *
37
     * @param Field $field
38
     */
39
    public function add(Field $field)
40
    {
41
        $this->fields->push($field);
42
    }
43
44
    /**
45
     * Get all filters in this column.
46
     *
47
     * @return Collection
48
     */
49
    public function fields()
50
    {
51
        return $this->fields;
52
    }
53
54
    /**
55
     * Set column width.
56
     *
57
     * @param int $width
58
     */
59
    public function setWidth($width)
60
    {
61
        $this->width = $width;
62
    }
63
64
    /**
65
     * Get column width.
66
     *
67
     * @return int
68
     */
69
    public function width()
70
    {
71
        return $this->width;
72
    }
73
}
74