Code Duplication    Length = 32-32 lines in 2 locations

src/Policy/AndPolicy.php 1 location

@@ 9-40 (lines=32) @@
6
7
use Chubbyphp\Deserialization\Denormalizer\DenormalizerContextInterface;
8
9
final class AndPolicy implements PolicyInterface
10
{
11
    /**
12
     * @var array|PolicyInterface[]
13
     */
14
    private $policies;
15
16
    /**
17
     * @param array|PolicyInterface[] $policies
18
     */
19
    public function __construct(array $policies)
20
    {
21
        $this->policies = $policies;
22
    }
23
24
    /**
25
     * @param DenormalizerContextInterface $context
26
     * @param object|mixed                 $object
27
     *
28
     * @return bool
29
     */
30
    public function isCompliant(DenormalizerContextInterface $context, $object): bool
31
    {
32
        foreach ($this->policies as $policy) {
33
            if (!$policy->isCompliant($context, $object)) {
34
                return false;
35
            }
36
        }
37
38
        return true;
39
    }
40
}
41

src/Policy/OrPolicy.php 1 location

@@ 9-40 (lines=32) @@
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
    public function __construct(array $policies)
20
    {
21
        $this->policies = $policies;
22
    }
23
24
    /**
25
     * @param DenormalizerContextInterface $context
26
     * @param object|mixed                 $object
27
     *
28
     * @return bool
29
     */
30
    public function isCompliant(DenormalizerContextInterface $context, $object): bool
31
    {
32
        foreach ($this->policies as $policy) {
33
            if ($policy->isCompliant($context, $object)) {
34
                return true;
35
            }
36
        }
37
38
        return false;
39
    }
40
}
41