| Total Complexity | 6 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class SortableColumnCollection extends Collection |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Checks whether the given column name can be sorted on. |
||
| 11 | * |
||
| 12 | * @param string $column |
||
| 13 | * @return bool |
||
| 14 | */ |
||
| 15 | function isValidColumn($column) |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Checks whether the given direction is a valid one for the column. |
||
| 24 | * |
||
| 25 | * @param string $column |
||
| 26 | * @param string $direction |
||
| 27 | * @return bool |
||
| 28 | */ |
||
| 29 | function isValidDirectionForColumn($column, $direction) |
||
| 30 | { |
||
| 31 | $column = $this->find($column); |
||
| 32 | |||
| 33 | if($column) { |
||
| 34 | return in_array($direction, $column->sorter->getDirections()); |
||
| 35 | } |
||
| 36 | |||
| 37 | return false; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Returns the SortableColumn with the given name or null if not found. |
||
| 42 | * |
||
| 43 | * @param $column |
||
| 44 | * @return SortableColumn|null |
||
| 45 | */ |
||
| 46 | function find($column) |
||
| 53 | } |
||
| 54 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.