Code Duplication    Length = 21-21 lines in 2 locations

Manager/PaymentLineManager.php 1 location

@@ 24-44 (lines=21) @@
21
22
        $methods = get_class_methods($dandomainPaymentLine);
23
24
        foreach ($methods as $method) {
25
            if ('get' === substr($method, 0, 3)) {
26
                $val = $dandomainPaymentLine->{$method}();
27
                $property = substr($method, 3);
28
            } elseif ('is' === substr($method, 0, 2)) {
29
                $val = $dandomainPaymentLine->{$method}();
30
                $property = substr($method, 2);
31
            } else {
32
                continue;
33
            }
34
35
            if (!is_scalar($val)) {
36
                continue;
37
            }
38
39
            $setter = 'set'.$property;
40
41
            if (method_exists($paymentLine, $setter)) {
42
                $paymentLine->{$setter}($val);
43
            }
44
        }
45
46
        return $paymentLine;
47
    }

Manager/PaymentManager.php 1 location

@@ 29-49 (lines=21) @@
26
27
        $methods = get_class_methods($paymentRequest);
28
29
        foreach ($methods as $method) {
30
            if ('get' === substr($method, 0, 3)) {
31
                $val = $paymentRequest->{$method}();
32
                $property = substr($method, 3);
33
            } elseif ('is' === substr($method, 0, 2)) {
34
                $val = $paymentRequest->{$method}();
35
                $property = substr($method, 2);
36
            } else {
37
                continue;
38
            }
39
40
            if (!is_scalar($val)) {
41
                continue;
42
            }
43
44
            $setter = 'set'.$property;
45
46
            if (method_exists($payment, $setter)) {
47
                $payment->{$setter}($val);
48
            }
49
        }
50
51
        foreach ($paymentRequest->getPaymentLines() as $paymentLine) {
52
            $newPaymentLine = $this->paymentLineManager->createPaymentLineFromDandomainPaymentRequest($paymentLine);