Total Complexity | 4 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class EnumCast extends Cast |
||
6 | { |
||
7 | /** |
||
8 | * @param \Illuminate\Database\Eloquent\Model $model |
||
9 | * @param string $key |
||
10 | * @param int|string|null|mixed $value |
||
11 | * @param array $attributes |
||
12 | * |
||
13 | * @return \Spatie\Enum\Enum|null |
||
14 | * |
||
15 | * @throws \BadMethodCallException |
||
16 | * @throws \Spatie\Enum\Laravel\Exceptions\NotNullableEnumField |
||
17 | */ |
||
18 | public function get($model, string $key, $value, array $attributes) |
||
19 | { |
||
20 | if (is_null($value)) { |
||
21 | return $this->handleNullValue($model, $key); |
||
|
|||
22 | } |
||
23 | |||
24 | return $this->asEnum($value); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param \Illuminate\Database\Eloquent\Model $model |
||
29 | * @param string $key |
||
30 | * @param int|string|\Spatie\Enum\Enum|null|mixed $value |
||
31 | * @param array $attributes |
||
32 | * |
||
33 | * @return int|string|null |
||
34 | * |
||
35 | * @throws \BadMethodCallException |
||
36 | * @throws \Spatie\Enum\Laravel\Exceptions\NotNullableEnumField |
||
37 | */ |
||
38 | public function set($model, string $key, $value, array $attributes) |
||
45 | } |
||
46 | } |
||
47 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.