Code Duplication    Length = 40-40 lines in 2 locations

src/Model/Checkout/Payment.php 1 location

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

src/Model/Checkout/Shipment.php 1 location

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