1
1
<?php
2
2
/*
3
- * Copyright 2022 Cloud Creativity Limited
3
+ * Copyright 2023 Cloud Creativity Limited
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
21
21
22
22
use Illuminate \Database \Eloquent \Builder ;
23
23
use Illuminate \Database \Eloquent \Model ;
24
- use InvalidArgumentException ;
25
24
use LaravelJsonApi \Eloquent \Drivers \StandardDriver ;
26
25
use Webkid \LaravelBooleanSoftdeletes \SoftDeletesBoolean ;
27
26
use function boolval ;
28
27
29
28
class SoftDeleteBooleanDriver extends StandardDriver
30
29
{
31
-
32
30
/**
33
31
* SoftDeleteDriver constructor.
34
32
*
35
- * @param Model| SoftDeletesBoolean $model
33
+ * @param Model& SoftDeletesBoolean $model
36
34
*/
37
35
public function __construct ($ model )
38
36
{
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
+ );
42
41
43
42
parent ::__construct ($ model );
44
43
}
@@ -91,7 +90,7 @@ public function destroy(Model $model): bool
91
90
}
92
91
93
92
/**
94
- * @param Model| SoftDeletesBoolean $model
93
+ * @param Model& SoftDeletesBoolean $model
95
94
* @return bool
96
95
*/
97
96
private function restore (Model $ model ): bool
@@ -102,7 +101,7 @@ private function restore(Model $model): bool
102
101
/**
103
102
* Will the hydration operation restore the model?
104
103
*
105
- * @param Model| SoftDeletesBoolean $model
104
+ * @param Model& SoftDeletesBoolean $model
106
105
* @return bool
107
106
*/
108
107
private function willRestore (Model $ model ): bool
@@ -119,7 +118,7 @@ private function willRestore(Model $model): bool
119
118
/**
120
119
* Will the hydration operation result in the model being soft deleted?
121
120
*
122
- * @param Model| SoftDeletesBoolean $model
121
+ * @param Model& SoftDeletesBoolean $model
123
122
* @return bool
124
123
*/
125
124
private function willSoftDelete (Model $ model ): bool
0 commit comments