ClosedOuterIteratorTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInnerIterator() 0 5 1
A throwClosedOuterIterator() 0 4 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