Completed
Pull Request — master (#290)
by
unknown
36:49 queued 34:03
created

ChoosePaymentMethod   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 0
dl 55
loc 55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A orderToken() 4 4 1
A paymentIdentifier() 4 4 1
A paymentMethod() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\SyliusShopApiPlugin\Command;
6
7
use Webmozart\Assert\Assert;
8
9 View Code Duplication
final class ChoosePaymentMethod
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private $paymentIdentifier;
15
16
    /**
17
     * @var string
18
     */
19
    private $paymentMethod;
20
21
    /**
22
     * @var string
23
     */
24
    private $orderToken;
25
26
    /**
27
     * @param string $orderToken
28
     * @param mixed $paymentIdentifier
29
     * @param string $paymentMethod
30
     */
31
    public function __construct($orderToken, $paymentIdentifier, $paymentMethod)
32
    {
33
        Assert::allString([$orderToken, $paymentMethod]);
34
35
        $this->orderToken = $orderToken;
36
        $this->paymentIdentifier = $paymentIdentifier;
37
        $this->paymentMethod = $paymentMethod;
38
    }
39
40
    /**
41
     * @return string
42
     */
43
    public function orderToken()
44
    {
45
        return $this->orderToken;
46
    }
47
48
    /**
49
     * @return mixed
50
     */
51
    public function paymentIdentifier()
52
    {
53
        return $this->paymentIdentifier;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function paymentMethod()
60
    {
61
        return $this->paymentMethod;
62
    }
63
}
64