ChainExclusionStrategy   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 57
c 0
b 0
f 0
wmc 10
lcom 1
cbo 1
ccs 0
cts 31
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A skipClass() 0 10 3
A skipProperty() 0 10 3
A skipType() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Serializer\Exclusion;
13
14
use Ivory\Serializer\Context\ContextInterface;
15
use Ivory\Serializer\Mapping\ClassMetadataInterface;
16
use Ivory\Serializer\Mapping\PropertyMetadataInterface;
17
use Ivory\Serializer\Mapping\TypeMetadataInterface;
18
19
/**
20
 * @author GeLo <[email protected]>
21
 */
22
class ChainExclusionStrategy implements ExclusionStrategyInterface
23
{
24
    /**
25
     * @var ExclusionStrategyInterface[]
26
     */
27
    private $strategies = [];
28
29
    /**
30
     * @param ExclusionStrategyInterface[] $strategies
31
     */
32
    public function __construct(array $strategies)
33
    {
34
        $this->strategies = $strategies;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function skipClass(ClassMetadataInterface $class, ContextInterface $context)
41
    {
42
        foreach ($this->strategies as $strategy) {
43
            if ($strategy->skipClass($class, $context)) {
44
                return true;
45
            }
46
        }
47
48
        return false;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function skipProperty(PropertyMetadataInterface $property, ContextInterface $context)
55
    {
56
        foreach ($this->strategies as $strategy) {
57
            if ($strategy->skipProperty($property, $context)) {
58
                return true;
59
            }
60
        }
61
62
        return false;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function skipType(TypeMetadataInterface $type, ContextInterface $context)
69
    {
70
        foreach ($this->strategies as $strategy) {
71
            if ($strategy->skipType($type, $context)) {
72
                return true;
73
            }
74
        }
75
76
        return false;
77
    }
78
}
79