These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Encore\Admin\Grid\Filter\Layout; |
||
4 | |||
5 | use Encore\Admin\Grid\Filter\AbstractFilter; |
||
6 | use Illuminate\Support\Collection; |
||
7 | |||
8 | View Code Duplication | class Column |
|
0 ignored issues
–
show
|
|||
9 | { |
||
10 | /** |
||
11 | * @var Collection |
||
12 | */ |
||
13 | protected $filters; |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $width; |
||
19 | |||
20 | /** |
||
21 | * Column constructor. |
||
22 | * |
||
23 | * @param int $width |
||
24 | */ |
||
25 | public function __construct($width = 12) |
||
26 | { |
||
27 | $this->width = $width; |
||
28 | $this->filters = new Collection(); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Add a filter to this column. |
||
33 | * |
||
34 | * @param AbstractFilter $filter |
||
35 | */ |
||
36 | public function addFilter(AbstractFilter $filter) |
||
37 | { |
||
38 | $this->filters->push($filter); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Get all filters in this column. |
||
43 | * |
||
44 | * @return Collection |
||
45 | */ |
||
46 | public function filters() |
||
47 | { |
||
48 | return $this->filters; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Set column width. |
||
53 | * |
||
54 | * @param int $width |
||
55 | */ |
||
56 | public function setWidth($width) |
||
57 | { |
||
58 | $this->width = $width; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Get column width. |
||
63 | * |
||
64 | * @return int |
||
65 | */ |
||
66 | public function width() |
||
67 | { |
||
68 | return $this->width; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Remove filter from column by id. |
||
73 | */ |
||
74 | public function removeFilterByID($id) |
||
75 | { |
||
76 | $this->filters = $this->filters->reject(function (AbstractFilter $filter) use ($id) { |
||
77 | return $filter->getId() == $id; |
||
78 | }); |
||
79 | } |
||
80 | } |
||
81 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.