OrPolicy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isCompliant() 0 9 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Policy;
6
7
use Chubbyphp\Deserialization\Denormalizer\DenormalizerContextInterface;
8
9
final class OrPolicy implements PolicyInterface
10
{
11
    /**
12
     * @var array|PolicyInterface[]
13
     */
14
    private $policies;
15
16
    /**
17
     * @param array|PolicyInterface[] $policies
18
     */
19 2
    public function __construct(array $policies)
20
    {
21 2
        $this->policies = $policies;
22 2
    }
23
24
    /**
25
     * @param object|mixed $object
26
     */
27
    public function isCompliant(DenormalizerContextInterface $context, $object): bool
28
    {
29
        foreach ($this->policies as $policy) {
30 2
            if ($policy->isCompliant($context, $object)) {
31
                return true;
32 2
            }
33 2
        }
34 2
35
        return false;
36
    }
37
}
38