TraversableCollectionTraversalStrategy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A traverse() 0 4 1
1
<?php
2
3
namespace Xsolve\Associate\CollectionTraversal;
4
5
use Xsolve\Associate\ObjectCollection\ObjectCollectionInterface;
6
7
class TraversableCollectionTraversalStrategy implements CollectionTraversalStrategyInterface
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function supports($propertyValue): bool
13
    {
14
        return $propertyValue instanceof \Traversable;
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function traverse(ObjectCollectionInterface $objectCollection, $propertyValue)
21
    {
22
        /* @var \Traversable $propertyValue */
23
        $objectCollection->addMany(iterator_to_array($propertyValue));
24
    }
25
}
26