Cancelled
Pull Request — master (#11)
by Laurens
23:42
created

PurchaseHistoryBuilder::buildFromJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LauLamanApps\IzettleApi\Client\Purchase;
6
7
use LauLamanApps\IzettleApi\API\Purchase\PurchaseHistory;
8
use Psr\Http\Message\ResponseInterface;
9
10
final class PurchaseHistoryBuilder implements PurchaseHistoryBuilderInterface
11
{
12
    private $purchaseBuilder;
13
14 1
    public function __construct(PurchaseBuilderInterface $purchaseBuilder)
15
    {
16 1
        $this->purchaseBuilder = $purchaseBuilder;
17 1
    }
18
19 1
    public function buildFromJson(string $jsonData): PurchaseHistory
20
    {
21 1
        $data =  json_decode($jsonData, true);
22
23 1
        return new PurchaseHistory(
24 1
            $data['firstPurchaseHash'],
25 1
            $data['lastPurchaseHash'],
26 1
            $this->purchaseBuilder->createFromJsonArray($data['purchases'])
0 ignored issues
show
Bug introduced by
The method createFromJsonArray() does not seem to exist on object<LauLamanApps\Izet...rchaseBuilderInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
        );
28
    }
29
}
30