Passed
Push — master ( 049c4c...7327a7 )
by Artem
01:51
created

PaymentRecords   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A createFromArray() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoman4eg\Nalog\Model\Tax;
5
6
use Shoman4eg\Nalog\Model\AbstractCollection;
7
use Shoman4eg\Nalog\Model\CreatableFromArray;
8
9
/**
10
 * @author Artem Dubinin <[email protected]>
11
 *
12
 * @extends AbstractCollection<Payment>
13
 */
14
final class PaymentRecords extends AbstractCollection implements CreatableFromArray
15
{
16
    private function __construct() {}
17
18
    /**
19
     * @throws \Exception
20
     */
21
    public static function createFromArray(array $data): self
22
    {
23
        $items = array_map(static fn (array $record) => Payment::createFromArray($record), $data['records']);
24
25
        $model = new self();
26
        $model->setItems($items);
27
28
        return $model;
29
    }
30
}
31