Passed
Branch master (117216)
by Pavel
08:06
created

ContextExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 16
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A extractContext() 0 4 1
A convert() 0 8 2
1
<?php
2
3
namespace Bankiru\Seo\Context;
4
5
use Bankiru\Seo\DestinationInterface;
6
7
final class ContextExtractor
8
{
9
    public function extractContext(DestinationInterface $destination)
10
    {
11
        return array_map([$this, 'convert'], iterator_to_array($destination));
12
    }
13
14
    private function convert($item)
15
    {
16
        if ($item instanceof ContextItemInterface) {
17
            return $item->getContext();
18
        }
19
20
        return $item;
21
    }
22
}
23