Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
3 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| InteractsWithTree | |
50.00% |
3 / 6 |
|
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 1 |
| checkModel | |
50.00% |
3 / 6 |
|
0.00% |
0 / 1 |
6.00 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Baril\Bonsai\Console\Concerns; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | use InvalidArgumentException; |
| 7 | |
| 8 | trait InteractsWithTree |
| 9 | { |
| 10 | protected function checkModel($model) |
| 11 | { |
| 12 | if ( |
| 13 | !class_exists($model) |
| 14 | || !is_subclass_of($model, Model::class) |
| 15 | || !method_exists($model, 'getClosureTable') |
| 16 | ) { |
| 17 | throw new InvalidArgumentException( |
| 18 | sprintf('%s is not a valid model class or does not use the BelongsToTree trait!', $model) |
| 19 | ); |
| 20 | } |
| 21 | } |
| 22 | } |