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

PurchaseHistoryBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildFromJson() 0 10 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