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 |
||
8 | class TDataServicesType extends IsOK |
||
9 | { |
||
10 | use IsOKToolboxTrait; |
||
11 | /** |
||
12 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema[] $schema |
||
13 | */ |
||
14 | private $schema = []; |
||
15 | |||
16 | /** |
||
17 | * @property string $maxDataServiceVersion |
||
18 | */ |
||
19 | private $maxDataServiceVersion; |
||
20 | |||
21 | /** |
||
22 | * @property string $dataServiceVersion |
||
23 | */ |
||
24 | private $dataServiceVersion; |
||
25 | |||
26 | public function __construct($maxDataServiceVersion = '3.0', $dataServiceVersion = '3.0') |
||
35 | |||
36 | /** |
||
37 | * Gets as MaxDataServiceVersion |
||
38 | * |
||
39 | * @return string |
||
40 | */ |
||
41 | public function getMaxDataServiceVersion() |
||
45 | |||
46 | /** |
||
47 | * Sets a new DataServiceVersion |
||
48 | * |
||
49 | * @param string $maxDataServiceVersion |
||
50 | * @return self |
||
51 | */ |
||
52 | public function setMaxDataServiceVersion($maxDataServiceVersion) |
||
62 | |||
63 | /** |
||
64 | * Gets as DataServiceVersion |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function getDataServiceVersion() |
||
72 | |||
73 | /** |
||
74 | * Sets a new DataServiceVersion |
||
75 | * |
||
76 | * @param string $dataServiceVersion |
||
77 | * @return self |
||
78 | */ |
||
79 | public function setDataServiceVersion($dataServiceVersion) |
||
89 | /** |
||
90 | * Adds as schema |
||
91 | * |
||
92 | * @return self |
||
93 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema $schema |
||
94 | */ |
||
95 | public function addToSchema(Schema $schema) |
||
104 | |||
105 | /** |
||
106 | * isset schema |
||
107 | * |
||
108 | * @param scalar $index |
||
109 | * @return boolean |
||
110 | */ |
||
111 | public function issetSchema($index) |
||
115 | |||
116 | /** |
||
117 | * unset schema |
||
118 | * |
||
119 | * @param scalar $index |
||
120 | * @return void |
||
121 | */ |
||
122 | public function unsetSchema($index) |
||
126 | |||
127 | /** |
||
128 | * Gets as schema |
||
129 | * |
||
130 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema[] |
||
131 | */ |
||
132 | public function getSchema() |
||
136 | |||
137 | /** |
||
138 | * Sets a new schema |
||
139 | * |
||
140 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\Schema[] $dataServices |
||
141 | * @return self |
||
142 | */ |
||
143 | public function setSchema(array $dataServices) |
||
155 | |||
156 | public function isOK(&$msg = null) |
||
179 | } |
||
180 |