ChooseShippingMethod   A
last analyzed

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 shipmentIdentifier() 4 4 1
A shippingMethod() 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\ShopApiPlugin\Command;
6
7
use Webmozart\Assert\Assert;
8
9 View Code Duplication
final class ChooseShippingMethod
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private $shipmentIdentifier;
15
16
    /**
17
     * @var string
18
     */
19
    private $shippingMethod;
20
21
    /**
22
     * @var string
23
     */
24
    private $orderToken;
25
26
    /**
27
     * @param string $orderToken
28
     * @param mixed $shipmentIdentifier
29
     * @param string $shippingMethod
30
     */
31
    public function __construct($orderToken, $shipmentIdentifier, $shippingMethod)
32
    {
33
        Assert::allString([$orderToken, $shippingMethod]);
34
35
        $this->orderToken = $orderToken;
36
        $this->shipmentIdentifier = $shipmentIdentifier;
37
        $this->shippingMethod = $shippingMethod;
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 shipmentIdentifier()
52
    {
53
        return $this->shipmentIdentifier;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function shippingMethod()
60
    {
61
        return $this->shippingMethod;
62
    }
63
}
64