OrderRequest   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 148
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 148
loc 148
rs 10
c 0
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setTargetWebshop() 5 5 1
A getTargetWebshop() 3 3 1
A setProducts() 5 5 1
A setHash() 5 5 1
A getHash() 3 3 1
A getProducts() 3 3 1
A getWebshop() 3 3 1
A setOrderReference() 5 5 1
A getOrderReference() 3 3 1
A setWebshop() 5 5 1
A __construct() 7 7 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
/*
4
 * This file is part of PHP CS Fixer.
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 *     Dariusz Rumiński <[email protected]>
8
 *
9
 * This source file is subject to the MIT license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Etrias\PaazlConnector\SoapTypes;
14
15
use Phpro\SoapClient\Type\RequestInterface;
16
17 View Code Duplication
class OrderRequest implements RequestInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * @var string
21
     */
22
    protected $hash = null;
23
24
    /**
25
     * @var int
26
     */
27
    protected $webshop = null;
28
29
    /**
30
     * @var int
31
     */
32
    protected $targetWebshop = null;
33
34
    /**
35
     * @var string
36
     */
37
    protected $orderReference = null;
38
39
    /**
40
     * @var products
41
     */
42
    protected $products = null;
43
44
    /**
45
     * Constructor.
46
     *
47
     * @var string
48
     * @var int       $webshop
49
     * @var int       $targetWebshop
50
     * @var string    $orderReference
51
     * @var Product[] $products
52
     *
53
     * @param mixed $hash
54
     * @param mixed $webshop
55
     * @param mixed $targetWebshop
56
     * @param mixed $orderReference
57
     */
58
    public function __construct($hash, $webshop, $targetWebshop, $orderReference, array $products)
59
    {
60
        $this->hash = $hash;
0 ignored issues
show
Documentation Bug introduced by
$hash is of type mixed, but the property $hash was declared to be of type string. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
61
        $this->webshop = $webshop;
62
        $this->targetWebshop = $targetWebshop;
63
        $this->orderReference = $orderReference;
64
        $this->products = $products;
0 ignored issues
show
Documentation Bug introduced by
It seems like $products of type Etrias\PaazlConnector\SoapTypes\Product[] is incompatible with the declared type Etrias\PaazlConnector\SoapTypes\products of property $products.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getHash()
71
    {
72
        return $this->hash;
73
    }
74
75
    /**
76
     * @param string $hash
77
     *
78
     * @return $this
79
     */
80
    public function setHash($hash)
81
    {
82
        $this->hash = $hash;
83
84
        return $this;
85
    }
86
87
    /**
88
     * @return int
89
     */
90
    public function getWebshop()
91
    {
92
        return $this->webshop;
93
    }
94
95
    /**
96
     * @param int $webshop
97
     *
98
     * @return $this
99
     */
100
    public function setWebshop($webshop)
101
    {
102
        $this->webshop = $webshop;
103
104
        return $this;
105
    }
106
107
    /**
108
     * @return int
109
     */
110
    public function getTargetWebshop()
111
    {
112
        return $this->targetWebshop;
113
    }
114
115
    /**
116
     * @param int $targetWebshop
117
     *
118
     * @return $this
119
     */
120
    public function setTargetWebshop($targetWebshop)
121
    {
122
        $this->targetWebshop = $targetWebshop;
123
124
        return $this;
125
    }
126
127
    /**
128
     * @return string
129
     */
130
    public function getOrderReference()
131
    {
132
        return $this->orderReference;
133
    }
134
135
    /**
136
     * @param string $orderReference
137
     *
138
     * @return $this
139
     */
140
    public function setOrderReference($orderReference)
141
    {
142
        $this->orderReference = $orderReference;
143
144
        return $this;
145
    }
146
147
    /**
148
     * @return Product[]
149
     */
150
    public function getProducts()
151
    {
152
        return $this->products;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->products returns the type Etrias\PaazlConnector\SoapTypes\products which is incompatible with the documented return type Etrias\PaazlConnector\SoapTypes\Product[].
Loading history...
153
    }
154
155
    /**
156
     * @param Product[] $products
157
     *
158
     * @return $this
159
     */
160
    public function setProducts(array $products)
161
    {
162
        $this->products = $products;
0 ignored issues
show
Documentation Bug introduced by
It seems like $products of type Etrias\PaazlConnector\SoapTypes\Product[] is incompatible with the declared type Etrias\PaazlConnector\SoapTypes\products of property $products.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
163
164
        return $this;
165
    }
166
}
167