DefaultProofOfDeliveryFactory::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 13
ccs 8
cts 8
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Inspirum\Balikobot\Model\ProofOfDelivery;
6
7
use Inspirum\Balikobot\Client\Response\Validator;
8
use function count;
9
10
final class DefaultProofOfDeliveryFactory implements ProofOfDeliveryFactory
11
{
12 35
    public function __construct(
13
        private readonly Validator $validator,
14
    ) {
15 35
    }
16
17
    /** @inheritDoc */
18 8
    public function create(array $carrierIds, array $data): array
19
    {
20 8
        unset($data['status']);
21 8
        $this->validator->validateIndexes($data, count($carrierIds));
22
23 5
        $fileUrls = [];
24 5
        foreach ($data as $item) {
25 5
            $this->validator->validateResponseStatus($item, $data);
26
27 4
            $fileUrls[] = $item['file_url'];
28
        }
29
30 2
        return $fileUrls;
31
    }
32
}
33