Passed
Pull Request — master (#1)
by De Cramer
07:10 queued 05:04
created

SelectConfig::isAllowMultiple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 1
c 1
b 1
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace oliverde8\ComfyBundle\Model;
5
6
7
use oliverde8\ComfyBundle\Manager\ConfigManagerInterface;
8
use Symfony\Component\Validator\Validator\ValidatorInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Valida...ator\ValidatorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class SelectConfig extends TextConfig
11
{
12
    /** @var string[] */
13
    protected $options = [];
14
15
    /** @var boolean */
16
    protected $allowMultiple;
17
18
    public function __construct(
19
        ConfigManagerInterface $configManager,
20
        ValidatorInterface $validator,
21
        string $path,
22
        string $name,
23
        string $description = "",
24
        int $scope = PHP_INT_MAX,
25
        ?string $defaultValue = null,
26
        bool $isHidden = false,
27
        $options = [],
28
        $allowMultiple = false
29
    ) {
30
        parent::__construct($configManager, $validator, $path, $name, $description, $scope, $defaultValue, $isHidden);
31
32
        $this->options = $options;
33
        $this->allowMultiple = $allowMultiple;
34
    }
35
36
37
    /**
38
     * Serialize value to save it in Database.
39
     *
40
     * @param $value
41
     *
42
     * @return string|null
43
     */
44
    protected function serialize($value): ?string
45
    {
46
        return json_encode($value);
47
    }
48
49
    /**
50
     * Deserialize value read from database.
51
     *
52
     * @param string|null $value
53
     *
54
     * @return mixed|null
55
     */
56
    protected function deserialize(?string $value)
57
    {
58
        return json_decode($value);
0 ignored issues
show
Bug introduced by
It seems like $value can also be of type null; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
        return json_decode(/** @scrutinizer ignore-type */ $value);
Loading history...
59
    }
60
61
    /**
62
     * @return string[]
63
     */
64
    public function getOptions()
65
    {
66
        return $this->options;
67
    }
68
69
    /**
70
     * @return bool
71
     */
72
    public function isAllowMultiple()
73
    {
74
        return $this->allowMultiple;
75
    }
76
77
78
}
79