ReadonlyCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 3
c 5
b 1
f 0
lcom 1
cbo 3
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createCollection() 0 4 1
A items() 0 6 1
1
<?php
2
3
namespace Nayjest\Collection\Decorator;
4
5
use Nayjest\Collection\Collection;
6
use Nayjest\Collection\CollectionReadInterface;
7
use Nayjest\Collection\CollectionReadTrait;
8
9
/**
10
 * Collection wrapper that allows only operations for data reading.
11
 */
12
class ReadonlyCollection implements CollectionReadInterface
13
{
14
    use CollectionReadTrait;
15
16
    private $collection;
17
    private $data;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param CollectionReadInterface $collection wrapped collection
23
     */
24 9
    public function __construct(CollectionReadInterface $collection)
25
    {
26 9
        $this->collection = $collection;
27 9
    }
28
29 1
    protected function createCollection(array $items)
30
    {
31 1
        return new static(new Collection($items));
32
    }
33
34 9
    protected function &items()
35
    {
36 9
        $this->data = $this->collection->toArray();
37
38 9
        return $this->data;
39
    }
40
}
41