Collection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 37
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 3 1
A all() 0 3 1
A __construct() 0 3 1
A values() 0 3 1
A each() 0 5 1
A filter() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSchool\CliMenu\Util;
6
7
class Collection
8
{
9
    /**
10
     * @var array
11
     */
12
    private $items;
13
14
    public function __construct(array $items)
15
    {
16
        $this->items = $items;
17
    }
18
19
    public function map(callable $cb) : self
20
    {
21
        return new self(mapWithKeys($this->items, $cb));
22
    }
23
24
    public function filter(callable $cb) : self
25
    {
26
        return new self(filter($this->items, $cb));
27
    }
28
29
    public function values() : self
30
    {
31
        return new self(array_values($this->items));
32
    }
33
34
    public function each(callable $cb) : self
35
    {
36
        each($this->items, $cb);
37
38
        return $this;
39
    }
40
41
    public function all() : array
42
    {
43
        return $this->items;
44
    }
45
}
46