1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Apie\OpenapiSchema\Concerns; |
5
|
|
|
|
6
|
|
|
use Apie\CompositeValueObjects\CompositeValueObjectTrait; |
7
|
|
|
use Apie\CompositeValueObjects\Exceptions\FieldMissingException; |
|
|
|
|
8
|
|
|
use Apie\OpenapiSchema\ValueObjects\SpecificationExtension; |
9
|
|
|
|
10
|
|
|
trait CompositeValueObjectWithExtension |
11
|
|
|
{ |
12
|
|
|
use CompositeValueObjectTrait { |
13
|
|
|
toNative as private internalToArray; |
14
|
|
|
fromNative as private internalFromArray; |
15
|
|
|
with as private internalWith; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var \Apie\OpenapiSchema\ValueObjects\SpecificationExtension|null |
20
|
|
|
*/ |
21
|
|
|
private $specificationExtension; |
22
|
|
|
|
23
|
|
|
public function toNative() |
24
|
|
|
{ |
25
|
|
|
$result = $this->internalToArray(); |
26
|
|
|
if (isset($result['specificationExtension'])) { |
27
|
|
|
$extensions = $result['specificationExtension']; |
28
|
|
|
unset($result['specificationExtension']); |
29
|
|
|
$result = array_merge($result, $extensions); |
30
|
|
|
} |
31
|
|
|
return array_filter( |
32
|
|
|
$result, |
33
|
|
|
function ($value) { |
34
|
|
|
return $value !== null; |
35
|
|
|
} |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public static function fromNative($input) |
40
|
|
|
{ |
41
|
|
|
unset($input['specificationExtension']); |
42
|
|
|
$list = []; |
43
|
|
|
$list['specificationExtension'] = []; |
44
|
|
|
foreach ($input as $key => $value) { |
45
|
|
|
if (stripos($key, 'x-') === 0) { |
46
|
|
|
$list['specificationExtension'][$key] = $value; |
47
|
|
|
} else { |
48
|
|
|
$list[$key] = $value; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
return self::internalFromArray($list); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function with(string $fieldName, $value): self |
55
|
|
|
{ |
56
|
|
|
if ($fieldName === 'specificationExtension') { |
57
|
|
|
throw new FieldMissingException($fieldName, $this); |
58
|
|
|
} |
59
|
|
|
if (stripos($fieldName, 'x-') === 0) { |
60
|
|
|
$object = clone $this; |
61
|
|
|
if ($object->specificationExtension) { |
62
|
|
|
$object->specificationExtension = $this->specificationExtension->withField($fieldName, $value); |
|
|
|
|
63
|
|
|
} else { |
64
|
|
|
$object->specificationExtension = new SpecificationExtension([$fieldName => $value]); |
65
|
|
|
} |
66
|
|
|
return $object; |
67
|
|
|
} |
68
|
|
|
return $this->internalWith($fieldName, $value); |
69
|
|
|
} |
70
|
|
|
} |
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