RequiresOuterIteratorTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 2
c 3
b 1
f 0
lcom 0
cbo 1
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testOuterIterator() 0 14 2
1
<?php
2
3
namespace Shrikeh\Collection;
4
5
use OuterIterator;
6
use Shrikeh\Collection\Exception\IncorrectInterface;
7
8
/**
9
 * Class RequiresOuterIteratorTrait
10
 * @package Shrikeh\Collection
11
 */
12
trait RequiresOuterIteratorTrait
13
{
14
    /**
15
     * Test that the given class is an instance of OuterIterator
16
     * @param $class
17
     * @throws IncorrectInterface if the class isn't an OuterIterator
18
     */
19
    private static function testOuterIterator($class)
20
    {
21
        if (!$class instanceof OuterIterator) {
22
            $msg = 'class %s uses trait %s but it is not an %s';
23
            throw new IncorrectInterface(
24
                sprintf(
25
                    $msg,
26
                    __CLASS__,
27
                    __TRAIT__,
28
                    OuterIterator::class
29
                )
30
            );
31
        }
32
    }
33
}
34