1 | <?php |
||
2 | |||
3 | namespace Ipag\Sdk\Model\Schema; |
||
4 | |||
5 | use Ipag\Sdk\Model\Schema\Exception\SchemaAttributeParseException; |
||
6 | use Ipag\Sdk\Util\StringUtil; |
||
0 ignored issues
–
show
|
|||
7 | |||
8 | /** |
||
9 | * @codeCoverageIgnore |
||
10 | */ |
||
11 | class SchemaAttribute |
||
12 | { |
||
13 | protected Schema $schema; |
||
14 | protected string $name; |
||
15 | protected ?string $visibleName; |
||
16 | protected bool $nullable; |
||
17 | protected bool $hidden; |
||
18 | protected $default; |
||
19 | protected $hasDefault; |
||
20 | |||
21 | public function __construct(Schema $schema, string $name) |
||
22 | { |
||
23 | $this->schema = $schema; |
||
24 | $this->name = $name; |
||
25 | $this->visibleName = null; |
||
26 | $this->nullable = false; |
||
27 | $this->hidden = false; |
||
28 | |||
29 | $this->default = null; |
||
30 | $this->hasDefault = false; |
||
31 | } |
||
32 | |||
33 | public function getName(): string |
||
34 | { |
||
35 | return $this->name; |
||
36 | } |
||
37 | |||
38 | public function setVisibleName(string $name): self |
||
39 | { |
||
40 | $this->visibleName = $name; |
||
41 | return $this; |
||
42 | } |
||
43 | |||
44 | public function getVisibleName(): string |
||
45 | { |
||
46 | return $this->visibleName ?? $this->getName(); |
||
47 | } |
||
48 | |||
49 | public function getAbsoluteName(): string |
||
50 | { |
||
51 | return implode('.', [$this->getSchema()->getName(), $this->getVisibleName()]); |
||
52 | } |
||
53 | |||
54 | public function getType(): string |
||
55 | { |
||
56 | return StringUtil::classBasename(get_class($this)); |
||
57 | } |
||
58 | |||
59 | public function getSchema(): Schema |
||
60 | { |
||
61 | return $this->schema; |
||
62 | } |
||
63 | |||
64 | public function getDefault() |
||
65 | { |
||
66 | return $this->default; |
||
67 | } |
||
68 | |||
69 | public function isNullable(): bool |
||
70 | { |
||
71 | return $this->nullable; |
||
72 | } |
||
73 | |||
74 | public function isHidden(): bool |
||
75 | { |
||
76 | return $this->hidden; |
||
77 | } |
||
78 | |||
79 | public function hasDefault(): bool |
||
80 | { |
||
81 | return $this->hasDefault; |
||
82 | } |
||
83 | |||
84 | // |
||
85 | |||
86 | public function nullable(bool $value = true): self |
||
87 | { |
||
88 | $this->nullable = $value; |
||
89 | return $this; |
||
90 | } |
||
91 | |||
92 | public function hidden(bool $value = true): self |
||
93 | { |
||
94 | $this->hidden = $value; |
||
95 | return $this; |
||
96 | } |
||
97 | |||
98 | public function default($value): self |
||
99 | { |
||
100 | $this->default = $value; |
||
101 | $this->hasDefault = true; |
||
102 | return $this; |
||
103 | } |
||
104 | |||
105 | public function array(): SchemaArrayAttribute |
||
106 | { |
||
107 | return $this->schema->array($this->getName(), $this); |
||
108 | } |
||
109 | |||
110 | public function list(): SchemaArrayAttribute |
||
111 | { |
||
112 | return $this->array(); |
||
113 | } |
||
114 | |||
115 | // |
||
116 | |||
117 | public function parse($value) |
||
118 | { |
||
119 | if (is_null($value) && $this->isNullable()) { |
||
120 | return $value; |
||
121 | } |
||
122 | |||
123 | return $this->parseContextual($value); |
||
124 | } |
||
125 | |||
126 | public function parseContextual($value) |
||
127 | { |
||
128 | return $value; |
||
129 | } |
||
130 | |||
131 | public function tryParse($value) |
||
132 | { |
||
133 | try { |
||
134 | return $this->parse($value); |
||
135 | } catch (SchemaAttributeParseException $e) { |
||
136 | return null; |
||
137 | } |
||
138 | } |
||
139 | |||
140 | public function serialize($value) |
||
141 | { |
||
142 | return $value; |
||
143 | } |
||
144 | |||
145 | public function copy(): self |
||
146 | { |
||
147 | return clone $this; |
||
148 | } |
||
149 | |||
150 | // |
||
151 | |||
152 | public static function from(Schema $schema, string $name): self |
||
153 | { |
||
154 | return new static($schema, $name); |
||
155 | } |
||
156 | } |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths