| Total Complexity | 45 |
| Total Lines | 572 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like SimpleUserTransfer often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SimpleUserTransfer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | final class SimpleUserTransfer extends \Micro\Library\DTO\Object\AbstractDto |
||
| 14 | { |
||
| 15 | protected SimpleObjectTransfer|null $parent = null; |
||
| 16 | |||
| 17 | #[\Symfony\Component\Validator\Constraints\Length(groups: ['Default'], max: 50, min: 6)] |
||
| 18 | #[\Symfony\Component\Validator\Constraints\Regex(groups: ['Default'], pattern: '/^(.[aA-zA]+)$/', match: true)] |
||
| 19 | protected string|null $username = null; |
||
| 20 | |||
| 21 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 22 | #[\Symfony\Component\Validator\Constraints\GreaterThan(groups: ['Default'], value: 18)] |
||
| 23 | #[\Symfony\Component\Validator\Constraints\LessThan(groups: ['Default'], value: 100)] |
||
| 24 | protected int|null $age = null; |
||
| 25 | |||
| 26 | #[\Symfony\Component\Validator\Constraints\Email(groups: ['Default'], mode: 'html5')] |
||
| 27 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 28 | protected string|null $email = null; |
||
| 29 | |||
| 30 | #[\Symfony\Component\Validator\Constraints\Ip(groups: ['Default'], version: '4')] |
||
| 31 | protected string|null $ip = null; |
||
| 32 | |||
| 33 | #[\Symfony\Component\Validator\Constraints\Hostname(groups: ['Default'], requireTld: false)] |
||
| 34 | protected string|null $hostname = null; |
||
| 35 | |||
| 36 | #[\Symfony\Component\Validator\Constraints\Regex(groups: ['Default'], pattern: '/^(.[a-z])+$/', match: true)] |
||
| 37 | protected string|null $sometext = null; |
||
| 38 | |||
| 39 | #[\Symfony\Component\Validator\Constraints\Url(groups: ['Default'], relativeProtocol: true)] |
||
| 40 | protected string|null $url = null; |
||
| 41 | |||
| 42 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 43 | #[\Symfony\Component\Validator\Constraints\Json(groups: ['Default'])] |
||
| 44 | protected string|null $json = null; |
||
| 45 | |||
| 46 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 47 | #[\Symfony\Component\Validator\Constraints\Uuid(groups: ['Default'], versions: [1, 2, 3, 4, 5, 6], strict: true)] |
||
| 48 | protected string|null $uuid = null; |
||
| 49 | |||
| 50 | #[\Symfony\Component\Validator\Constraints\DateTime(groups: ['Default'], format: 'Y-m-d H:i:s')] |
||
| 51 | protected string|null $created_at = null; |
||
| 52 | |||
| 53 | #[\Symfony\Component\Validator\Constraints\Date(groups: ['Default'])] |
||
| 54 | protected string|null $updated_at = null; |
||
| 55 | |||
| 56 | #[\Symfony\Component\Validator\Constraints\Timezone(groups: ['Default'], countryCode: 'BY', intlCompatible: true, zone: 4096)] |
||
| 57 | protected string|null $timezone = null; |
||
| 58 | |||
| 59 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 60 | #[\Symfony\Component\Validator\Constraints\CardScheme(groups: ['Default'], schemes: ['MASTERCARD'])] |
||
| 61 | #[\Symfony\Component\Validator\Constraints\Luhn(groups: ['Default'])] |
||
| 62 | protected string|null $card_scheme = null; |
||
| 63 | |||
| 64 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 65 | #[\Symfony\Component\Validator\Constraints\Bic(groups: ['Default'])] |
||
| 66 | protected string|null $bic = null; |
||
| 67 | |||
| 68 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 69 | #[\Symfony\Component\Validator\Constraints\Currency(groups: ['Default'])] |
||
| 70 | protected string|null $currency = null; |
||
| 71 | |||
| 72 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 73 | #[\Symfony\Component\Validator\Constraints\Iban(groups: ['Default'])] |
||
| 74 | protected string|null $iban = null; |
||
| 75 | |||
| 76 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 77 | #[\Symfony\Component\Validator\Constraints\Isbn(groups: ['Default'], type: 'isbn13')] |
||
| 78 | protected string|null $isbn = null; |
||
| 79 | |||
| 80 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 81 | #[\Symfony\Component\Validator\Constraints\Issn(groups: ['Default'])] |
||
| 82 | protected string|null $issn = null; |
||
| 83 | |||
| 84 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 85 | #[\Symfony\Component\Validator\Constraints\Isin(groups: ['Default'])] |
||
| 86 | protected string|null $isin = null; |
||
| 87 | |||
| 88 | #[\Symfony\Component\Validator\Constraints\NotBlank(groups: ['Default'], allowNull: false)] |
||
| 89 | #[\Symfony\Component\Validator\Constraints\Choice(groups: ['Default'], choices: [1, 'example', 0.001, true])] |
||
| 90 | protected string|int|float|array|null $choice = null; |
||
| 91 | |||
| 92 | #[\Symfony\Component\Validator\Constraints\Expression(groups: ['Default'], expression: 'this.getChoice() === excepted', values: ['excepted' => 'example'])] |
||
| 93 | protected string|int|null $expression = null; |
||
| 94 | |||
| 95 | public function getParent(): SimpleObjectTransfer|null |
||
| 96 | { |
||
| 97 | return $this->parent; |
||
| 98 | } |
||
| 99 | |||
| 100 | public function getUsername(): string|null |
||
| 101 | { |
||
| 102 | return $this->username; |
||
| 103 | } |
||
| 104 | |||
| 105 | public function getAge(): int|null |
||
| 106 | { |
||
| 107 | return $this->age; |
||
| 108 | } |
||
| 109 | |||
| 110 | public function getEmail(): string|null |
||
| 111 | { |
||
| 112 | return $this->email; |
||
| 113 | } |
||
| 114 | |||
| 115 | public function getIp(): string|null |
||
| 116 | { |
||
| 117 | return $this->ip; |
||
| 118 | } |
||
| 119 | |||
| 120 | public function getHostname(): string|null |
||
| 121 | { |
||
| 122 | return $this->hostname; |
||
| 123 | } |
||
| 124 | |||
| 125 | public function getSometext(): string|null |
||
| 126 | { |
||
| 127 | return $this->sometext; |
||
| 128 | } |
||
| 129 | |||
| 130 | public function getUrl(): string|null |
||
| 133 | } |
||
| 134 | |||
| 135 | public function getJson(): string|null |
||
| 136 | { |
||
| 137 | return $this->json; |
||
| 138 | } |
||
| 139 | |||
| 140 | public function getUuid(): string|null |
||
| 141 | { |
||
| 142 | return $this->uuid; |
||
| 143 | } |
||
| 144 | |||
| 145 | public function getCreatedAt(): string|null |
||
| 146 | { |
||
| 147 | return $this->created_at; |
||
| 148 | } |
||
| 149 | |||
| 150 | public function getUpdatedAt(): string|null |
||
| 151 | { |
||
| 152 | return $this->updated_at; |
||
| 153 | } |
||
| 154 | |||
| 155 | public function getTimezone(): string|null |
||
| 156 | { |
||
| 157 | return $this->timezone; |
||
| 158 | } |
||
| 159 | |||
| 160 | public function getCardScheme(): string|null |
||
| 161 | { |
||
| 162 | return $this->card_scheme; |
||
| 163 | } |
||
| 164 | |||
| 165 | public function getBic(): string|null |
||
| 166 | { |
||
| 167 | return $this->bic; |
||
| 168 | } |
||
| 169 | |||
| 170 | public function getCurrency(): string|null |
||
| 171 | { |
||
| 172 | return $this->currency; |
||
| 173 | } |
||
| 174 | |||
| 175 | public function getIban(): string|null |
||
| 176 | { |
||
| 177 | return $this->iban; |
||
| 178 | } |
||
| 179 | |||
| 180 | public function getIsbn(): string|null |
||
| 181 | { |
||
| 182 | return $this->isbn; |
||
| 183 | } |
||
| 184 | |||
| 185 | public function getIssn(): string|null |
||
| 186 | { |
||
| 187 | return $this->issn; |
||
| 188 | } |
||
| 189 | |||
| 190 | public function getIsin(): string|null |
||
| 191 | { |
||
| 192 | return $this->isin; |
||
| 193 | } |
||
| 194 | |||
| 195 | public function getChoice(): string|int|float|array|null |
||
| 196 | { |
||
| 197 | return $this->choice; |
||
| 198 | } |
||
| 199 | |||
| 200 | public function getExpression(): string|int|null |
||
| 201 | { |
||
| 202 | return $this->expression; |
||
| 203 | } |
||
| 204 | |||
| 205 | public function setParent(SimpleObjectTransfer|null $parent): self |
||
| 206 | { |
||
| 207 | $this->parent = $parent; |
||
| 208 | |||
| 209 | return $this; |
||
| 210 | } |
||
| 211 | |||
| 212 | public function setUsername(string|null $username): self |
||
| 213 | { |
||
| 214 | $this->username = $username; |
||
| 215 | |||
| 216 | return $this; |
||
| 217 | } |
||
| 218 | |||
| 219 | public function setAge(int|null $age): self |
||
| 220 | { |
||
| 221 | $this->age = $age; |
||
| 222 | |||
| 223 | return $this; |
||
| 224 | } |
||
| 225 | |||
| 226 | public function setEmail(string|null $email): self |
||
| 227 | { |
||
| 228 | $this->email = $email; |
||
| 229 | |||
| 230 | return $this; |
||
| 231 | } |
||
| 232 | |||
| 233 | public function setIp(string|null $ip): self |
||
| 234 | { |
||
| 235 | $this->ip = $ip; |
||
| 236 | |||
| 237 | return $this; |
||
| 238 | } |
||
| 239 | |||
| 240 | public function setHostname(string|null $hostname): self |
||
| 241 | { |
||
| 242 | $this->hostname = $hostname; |
||
| 243 | |||
| 244 | return $this; |
||
| 245 | } |
||
| 246 | |||
| 247 | public function setSometext(string|null $sometext): self |
||
| 248 | { |
||
| 249 | $this->sometext = $sometext; |
||
| 250 | |||
| 251 | return $this; |
||
| 252 | } |
||
| 253 | |||
| 254 | public function setUrl(string|null $url): self |
||
| 255 | { |
||
| 256 | $this->url = $url; |
||
| 257 | |||
| 258 | return $this; |
||
| 259 | } |
||
| 260 | |||
| 261 | public function setJson(string|null $json): self |
||
| 262 | { |
||
| 263 | $this->json = $json; |
||
| 264 | |||
| 265 | return $this; |
||
| 266 | } |
||
| 267 | |||
| 268 | public function setUuid(string|null $uuid): self |
||
| 269 | { |
||
| 270 | $this->uuid = $uuid; |
||
| 271 | |||
| 272 | return $this; |
||
| 273 | } |
||
| 274 | |||
| 275 | public function setCreatedAt(string|null $created_at): self |
||
| 276 | { |
||
| 277 | $this->created_at = $created_at; |
||
| 278 | |||
| 279 | return $this; |
||
| 280 | } |
||
| 281 | |||
| 282 | public function setUpdatedAt(string|null $updated_at): self |
||
| 283 | { |
||
| 284 | $this->updated_at = $updated_at; |
||
| 285 | |||
| 286 | return $this; |
||
| 287 | } |
||
| 288 | |||
| 289 | public function setTimezone(string|null $timezone): self |
||
| 294 | } |
||
| 295 | |||
| 296 | public function setCardScheme(string|null $card_scheme): self |
||
| 301 | } |
||
| 302 | |||
| 303 | public function setBic(string|null $bic): self |
||
| 304 | { |
||
| 305 | $this->bic = $bic; |
||
| 306 | |||
| 307 | return $this; |
||
| 308 | } |
||
| 309 | |||
| 310 | public function setCurrency(string|null $currency): self |
||
| 311 | { |
||
| 312 | $this->currency = $currency; |
||
| 313 | |||
| 314 | return $this; |
||
| 315 | } |
||
| 316 | |||
| 317 | public function setIban(string|null $iban): self |
||
| 322 | } |
||
| 323 | |||
| 324 | public function setIsbn(string|null $isbn): self |
||
| 325 | { |
||
| 326 | $this->isbn = $isbn; |
||
| 327 | |||
| 328 | return $this; |
||
| 329 | } |
||
| 330 | |||
| 331 | public function setIssn(string|null $issn): self |
||
| 332 | { |
||
| 333 | $this->issn = $issn; |
||
| 334 | |||
| 335 | return $this; |
||
| 336 | } |
||
| 337 | |||
| 338 | public function setIsin(string|null $isin): self |
||
| 343 | } |
||
| 344 | |||
| 345 | public function setChoice(string|int|float|array|null $choice): self |
||
| 346 | { |
||
| 347 | $this->choice = $choice; |
||
| 348 | |||
| 349 | return $this; |
||
| 350 | } |
||
| 351 | |||
| 352 | public function setExpression(string|int|null $expression): self |
||
| 353 | { |
||
| 354 | $this->expression = $expression; |
||
| 355 | |||
| 356 | return $this; |
||
| 357 | } |
||
| 358 | |||
| 359 | protected static function attributesMetadata(): array |
||
| 360 | { |
||
| 361 | return array ( |
||
| 362 | 'parent' => |
||
| 363 | array ( |
||
| 364 | 'type' => |
||
| 365 | array ( |
||
| 366 | 0 => 'Transfer\\Simple\\SimpleObjectTransfer', |
||
| 367 | 1 => 'null', |
||
| 368 | ), |
||
| 369 | 'required' => false, |
||
| 370 | 'actionName' => 'parent', |
||
| 371 | ), |
||
| 372 | 'username' => |
||
| 373 | array ( |
||
| 374 | 'type' => |
||
| 375 | array ( |
||
| 376 | 0 => 'string', |
||
| 585 | ), |
||
| 586 | ); |
||
| 587 | } |
||
| 588 | } |
||
| 589 |