11<?php
22/*
3- * Copyright 2022 Cloud Creativity Limited
3+ * Copyright 2023 Cloud Creativity Limited
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
66 * you may not use this file except in compliance with the License.
2121
2222use Illuminate \Database \Eloquent \Builder ;
2323use Illuminate \Database \Eloquent \Model ;
24- use InvalidArgumentException ;
2524use LaravelJsonApi \Eloquent \Drivers \StandardDriver ;
2625use Webkid \LaravelBooleanSoftdeletes \SoftDeletesBoolean ;
2726use function boolval ;
2827
2928class SoftDeleteBooleanDriver extends StandardDriver
3029{
31-
3230 /**
3331 * SoftDeleteDriver constructor.
3432 *
35- * @param Model| SoftDeletesBoolean $model
33+ * @param Model& SoftDeletesBoolean $model
3634 */
3735 public function __construct ($ model )
3836 {
39- if (!in_array (SoftDeletesBoolean::class, class_uses_recursive ($ model ), true )) {
40- throw new InvalidArgumentException ('Expecting a model that is boolean soft-deletable. ' );
41- }
37+ assert (
38+ in_array (SoftDeletesBoolean::class, class_uses_recursive ($ model ), true ),
39+ 'Expecting a model that is boolean soft-deletable. ' ,
40+ );
4241
4342 parent ::__construct ($ model );
4443 }
@@ -91,7 +90,7 @@ public function destroy(Model $model): bool
9190 }
9291
9392 /**
94- * @param Model| SoftDeletesBoolean $model
93+ * @param Model& SoftDeletesBoolean $model
9594 * @return bool
9695 */
9796 private function restore (Model $ model ): bool
@@ -102,7 +101,7 @@ private function restore(Model $model): bool
102101 /**
103102 * Will the hydration operation restore the model?
104103 *
105- * @param Model| SoftDeletesBoolean $model
104+ * @param Model& SoftDeletesBoolean $model
106105 * @return bool
107106 */
108107 private function willRestore (Model $ model ): bool
@@ -119,7 +118,7 @@ private function willRestore(Model $model): bool
119118 /**
120119 * Will the hydration operation result in the model being soft deleted?
121120 *
122- * @param Model| SoftDeletesBoolean $model
121+ * @param Model& SoftDeletesBoolean $model
123122 * @return bool
124123 */
125124 private function willSoftDelete (Model $ model ): bool
0 commit comments