DepositCollection::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 1
dl 0
loc 9
ccs 4
cts 5
cp 0.8
crap 2.032
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MidasSoft\DominicanBankParser\Collections;
4
5
use MidasSoft\DominicanBankParser\Deposit;
6
use MidasSoft\DominicanBankParser\Exceptions\InvalidArgumentException;
7
use Tightenco\Collect\Support\Collection;
8
9
class DepositCollection extends Collection
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 13
    public function __construct($items = [])
15
    {
16
        array_walk($items, function ($value) {
17 1
            if (!$value instanceof Deposit) {
18
                throw new InvalidArgumentException('You should pass only Deposit objects to this collection.');
19
            }
20 13
        });
21
22 13
        parent::__construct($items);
23 13
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 8
    public function push($value)
29
    {
30 8
        if (!$value instanceof Deposit) {
31
            throw new InvalidArgumentException('You should pass only Deposit objects to this collection.');
32
        }
33
34 8
        parent::push($value);
35 8
    }
36
}
37