Code Duplication    Length = 42-42 lines in 2 locations

src/Model/Checkout/PaymentCollection.php 1 location

@@ 17-58 (lines=42) @@
14
/**
15
 * @author Kasim Taskin <[email protected]>
16
 */
17
final class PaymentCollection implements CreatableFromArray
18
{
19
    /**
20
     * @var Payment[]
21
     */
22
    private $payments;
23
24
    /**
25
     * PaymentCollection constructor.
26
     *
27
     * @param array|Shipment[] $payments
28
     */
29
    private function __construct(array $payments)
30
    {
31
        $this->payments = $payments;
32
    }
33
34
    /**
35
     * @return Shipment
36
     */
37
    public static function createFromArray(array $data): self
38
    {
39
        $payments = [];
40
        if (!empty($data)) {
41
            foreach ($data['payments'] as $payment) {
42
                $payments[] = Payment::createFromArray($payment);
43
            }
44
        }
45
46
        return new self($payments);
47
    }
48
49
    /**
50
     * @return Payment[]
51
     */
52
    public function getPayments(): array
53
    {
54
        return $this->payments;
55
    }
56
}
57

src/Model/Checkout/ShipmentCollection.php 1 location

@@ 17-58 (lines=42) @@
14
/**
15
 * @author Kasim Taskin <[email protected]>
16
 */
17
final class ShipmentCollection implements CreatableFromArray
18
{
19
    /**
20
     * @var Shipment[]
21
     */
22
    private $shipments;
23
24
    /**
25
     * Shipment constructor.
26
     *
27
     * @param array|Shipment[] $shipments
28
     */
29
    private function __construct(array $shipments)
30
    {
31
        $this->shipments = $shipments;
32
    }
33
34
    /**
35
     * @return Shipment
36
     */
37
    public static function createFromArray(array $data): self
38
    {
39
        $shipments = [];
40
        if (!empty($data)) {
41
            foreach ($data['shipments'] as $shipment) {
42
                $shipments[] = Shipment::createFromArray($shipment);
43
            }
44
        }
45
46
        return new self($shipments);
47
    }
48
49
    /**
50
     * @return Shipment[]
51
     */
52
    public function getShipments(): array
53
    {
54
        return $this->shipments;
55
    }
56
}
57