RequiresOuterIteratorTrait::testOuterIterator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 14
rs 9.4285
c 2
b 1
f 0
cc 2
eloc 9
nc 2
nop 1
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