throwClosedOuterIterator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Shrikeh\Collection;
3
4
use Shrikeh\Collection\Exception\ClosedOuterIterator;
5
6
/**
7
 * Trait ClosedOuterIteratorTrait
8
 * @package Shrikeh\Collection
9
 */
10
trait ClosedOuterIteratorTrait
11
{
12
    /**
13
     * Remove access to the interface-defined getInnerIterator(), therefore
14
     * enforcing immutability.
15
     *
16
     * @throws ClosedOuterIterator
17
     */
18
    final public function getInnerIterator()
19
    {
20
        $msg = 'Collection %s does not allow access to the inner iterator.';
21
        $this->throwClosedOuterIterator(sprintf($msg, static::class));
22
    }
23
24
    /**
25
     * @param $msg The message in the exception.
26
     */
27
    private function throwClosedOuterIterator($msg)
28
    {
29
        throw new ClosedOuterIterator($msg);
30
    }
31
}
32