Completed
Push — master ( 8bf0fe...b37564 )
by Song
05:18 queued 03:01
created

CanFixColumns::fixColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Concerns;
4
5
use Encore\Admin\Grid\Tools\FixColumns;
6
use Illuminate\Support\Collection;
7
8
trait CanFixColumns
9
{
10
    /**
11
     * @var FixColumns
12
     */
13
    protected $fixColumns;
14
15
    /**
16
     * @param int $head
17
     * @param int $tail
18
     */
19
    public function fixColumns(int $head, int $tail = -1)
20
    {
21
        $this->fixColumns = new FixColumns($this, $head, $tail);
22
23
        $this->rendering($this->fixColumns->apply());
0 ignored issues
show
Bug introduced by
It seems like rendering() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
24
    }
25
26
    /**
27
     * @return Collection
28
     */
29
    public function leftVisibleColumns()
30
    {
31
        return $this->fixColumns->leftColumns();
32
    }
33
34
    /**
35
     * @return Collection
36
     */
37
    public function rightVisibleColumns()
38
    {
39
        return $this->fixColumns->rightColumns();
40
    }
41
}
42
43