GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EnumCast::set()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 4
1
<?php
2
3
namespace Spatie\Enum\Laravel\Casts;
4
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);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->handleNullValue($model, $key) targeting Spatie\Enum\Laravel\Casts\Cast::handleNullValue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

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.

Loading history...
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)
39
    {
40
        if (is_null($value)) {
41
            return $this->handleNullValue($model, $key);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->handleNullValue($model, $key) targeting Spatie\Enum\Laravel\Casts\Cast::handleNullValue() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

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.

Loading history...
42
        }
43
44
        return $this->asEnum($value)->value;
45
    }
46
}
47