| 1 | <?php |
||
| 8 | trait HasTotalRow |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | protected $totalRowColumns = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @param string $column |
||
| 17 | * @param Closure $callback |
||
| 18 | * |
||
| 19 | * @return $this |
||
| 20 | */ |
||
| 21 | public function addTotalRow($column, $callback) |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string |
||
| 30 | */ |
||
| 31 | public function renderTotalRow() |
||
| 45 | } |
||
| 46 |
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
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). 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.