1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Apie\TypeJuggling; |
5
|
|
|
|
6
|
|
|
use Apie\TypeJuggling\Exceptions\CanNotCallFromNativeWithAbstractClassOrInterface; |
7
|
|
|
use Apie\TypeJuggling\Exceptions\MissingValueException; |
8
|
|
|
use Apie\TypeJuggling\Exceptions\OnlyValueObjectInterfaceSupportException; |
9
|
|
|
use Apie\ValueObjects\ValueObjectInterface; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class AnotherValueObject implements TypeUtilInterface |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
private $fieldName; |
17
|
|
|
/** |
18
|
|
|
* @var string |
19
|
|
|
*/ |
20
|
|
|
private $className; |
21
|
|
|
|
22
|
|
|
public function __construct(string $fieldName, ?string $className) |
23
|
|
|
{ |
24
|
|
|
if ($className === null || !is_a($className, ValueObjectInterface::class, true)) { |
25
|
|
|
throw new OnlyValueObjectInterfaceSupportException($fieldName, $className); |
26
|
|
|
} |
27
|
|
|
$this->fieldName = $fieldName; |
28
|
|
|
$this->className = $className; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function fromNative($input) |
32
|
|
|
{ |
33
|
|
|
if (is_callable([$this->className, 'fromNative'])) { |
34
|
|
|
return $this->className::fromNative($input); |
35
|
|
|
} |
36
|
|
|
throw new CanNotCallFromNativeWithAbstractClassOrInterface($this->className); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function toNative($input) |
40
|
|
|
{ |
41
|
|
|
return $input instanceof ValueObjectInterface ? $input->toNative() : null; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function fromMissingValue() |
45
|
|
|
{ |
46
|
|
|
throw new MissingValueException($this->fieldName); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function supports($input): bool |
50
|
|
|
{ |
51
|
|
|
return is_a($input, $this->className); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function supportsToNative($input): bool |
55
|
|
|
{ |
56
|
|
|
return $this->supports($input); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function supportsFromNative($input): bool |
60
|
|
|
{ |
61
|
|
|
$res = is_callable([$this->className, 'fromNative']); |
62
|
|
|
if (!$res) { |
63
|
|
|
return false; |
64
|
|
|
} |
65
|
|
|
if (is_callable([$this->className, 'supportsFromNative'])) { |
66
|
|
|
return (bool) $this->className::supportsFromNative($input); |
67
|
|
|
} |
68
|
|
|
return true; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function __toString() |
72
|
|
|
{ |
73
|
|
|
return $this->className; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
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