| Conditions | 4 |
| Paths | 3 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function addCheckbox(array $attributes = [], $position = false) |
||
| 17 | { |
||
| 18 | $attributes = array_merge([ |
||
| 19 | 'defaultContent' => '<input type="checkbox" ' . $this->html->attributes($attributes) . '/>', |
||
|
|
|||
| 20 | 'title' => '<input type="checkbox" ' . $this->html->attributes($attributes + ['id' => 'dataTablesCheckbox']) . '/>', |
||
| 21 | 'data' => 'checkbox', |
||
| 22 | 'name' => 'checkbox', |
||
| 23 | 'orderable' => false, |
||
| 24 | 'searchable' => false, |
||
| 25 | 'exportable' => false, |
||
| 26 | 'printable' => true, |
||
| 27 | 'width' => '10px', |
||
| 28 | ], $attributes); |
||
| 29 | |||
| 30 | $column = new Column($attributes); |
||
| 31 | |||
| 32 | if ($position === true) { |
||
| 33 | $this->collection->prepend($column); |
||
| 34 | } elseif ($position === false || $position >= $this->collection->count()) { |
||
| 35 | $this->collection->push($column); |
||
| 36 | } else { |
||
| 37 | $this->collection->splice($position, 0, [$column]); |
||
| 38 | } |
||
| 39 | |||
| 40 | return $this; |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: