Passed
Pull Request — master (#32)
by Artem
01:33
created

PaymentRecords::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
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
 * @method Payment current()
12
 */
13
final class PaymentRecords extends AbstractCollection implements CreatableFromArray
14
{
15
    private function __construct()
16
    {
17
    }
18
19
    /**
20
     * @throws \Exception
21
     */
22
    public static function createFromArray(array $data): self
23
    {
24
        $items = array_map(static fn ($record) => Payment::createFromArray($record), $data['records']);
25
26
        $model = new self();
27
        $model->setItems($items);
28
29
        return $model;
30
    }
31
}
32