| @@ 22-38 (lines=17) @@ | ||
| 19 | * @return CrudTable |
|
| 20 | * @throws InvalidArgumentException |
|
| 21 | */ |
|
| 22 | public static function table($crudable) |
|
| 23 | { |
|
| 24 | if (is_string($crudable)) |
|
| 25 | { |
|
| 26 | return new CrudTable(new $crudable); |
|
| 27 | } |
|
| 28 | else if ($crudable instanceof CrudTable) |
|
| 29 | { |
|
| 30 | return $crudable; |
|
| 31 | } |
|
| 32 | else if (is_object($crudable) && array_key_exists(Crudable::class, class_uses($crudable))) |
|
| 33 | { |
|
| 34 | return new CrudTable($crudable); |
|
| 35 | } |
|
| 36 | ||
| 37 | throw new InvalidArgumentException("Argument must be Crudable."); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @param string|Crudable $crudable |
|
| @@ 45-61 (lines=17) @@ | ||
| 42 | * @return CrudEntry |
|
| 43 | * @throws InvalidArgumentException |
|
| 44 | */ |
|
| 45 | public static function entry($crudable) |
|
| 46 | { |
|
| 47 | if (is_string($crudable)) |
|
| 48 | { |
|
| 49 | return new CrudEntry(new $crudable); |
|
| 50 | } |
|
| 51 | else if ($crudable instanceof CrudEntry) |
|
| 52 | { |
|
| 53 | return $crudable; |
|
| 54 | } |
|
| 55 | else if (is_object($crudable) && array_key_exists(Crudable::class, class_uses($crudable))) |
|
| 56 | { |
|
| 57 | return new CrudEntry($crudable); |
|
| 58 | } |
|
| 59 | ||
| 60 | throw new InvalidArgumentException("Argument must be Crudable."); |
|
| 61 | } |
|
| 62 | } |
|
| 63 | ||