| Total Complexity | 52 |
| Total Lines | 560 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like PlaylistDataProvider 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 PlaylistDataProvider, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 8 | final class PlaylistDataProvider extends \Xervice\DataProvider\Business\Model\DataProvider\AbstractDataProvider implements \Xervice\DataProvider\Business\Model\DataProvider\DataProviderInterface |
||
| 9 | { |
||
| 10 | /** @var string */ |
||
| 11 | protected $description; |
||
| 12 | |||
| 13 | /** @var \SpotifyApiConnect\Domain\DataTransferObject\ExternalUrlDataProvider */ |
||
| 14 | protected $external_urls; |
||
| 15 | |||
| 16 | /** @var \SpotifyApiConnect\Domain\DataTransferObject\FollowersDataProvider */ |
||
| 17 | protected $followers; |
||
| 18 | |||
| 19 | /** @var string */ |
||
| 20 | protected $id; |
||
| 21 | |||
| 22 | /** @var string */ |
||
| 23 | protected $href; |
||
| 24 | |||
| 25 | /** @var string */ |
||
| 26 | protected $name; |
||
| 27 | |||
| 28 | /** @var bool */ |
||
| 29 | protected $public; |
||
| 30 | |||
| 31 | /** @var \SpotifyApiConnect\Domain\DataTransferObject\PlaylistTracksDataProvider */ |
||
| 32 | protected $tracks; |
||
| 33 | |||
| 34 | /** @var string */ |
||
| 35 | protected $type; |
||
| 36 | |||
| 37 | /** @var string */ |
||
| 38 | protected $uri; |
||
| 39 | |||
| 40 | |||
| 41 | /** |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | public function getDescription(): ?string |
||
| 45 | { |
||
| 46 | return $this->description; |
||
| 47 | } |
||
| 48 | |||
| 49 | |||
| 50 | /** |
||
| 51 | * @param string $description |
||
| 52 | * @return PlaylistDataProvider |
||
| 53 | */ |
||
| 54 | public function setDescription(?string $description = null) |
||
| 55 | { |
||
| 56 | $this->description = $description; |
||
| 57 | |||
| 58 | return $this; |
||
| 59 | } |
||
| 60 | |||
| 61 | |||
| 62 | /** |
||
| 63 | * @return PlaylistDataProvider |
||
| 64 | */ |
||
| 65 | public function unsetDescription() |
||
| 66 | { |
||
| 67 | $this->description = null; |
||
| 68 | |||
| 69 | return $this; |
||
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | /** |
||
| 74 | * @return bool |
||
| 75 | */ |
||
| 76 | public function hasDescription() |
||
| 77 | { |
||
| 78 | return ($this->description !== null && $this->description !== []); |
||
| 79 | } |
||
| 80 | |||
| 81 | |||
| 82 | /** |
||
| 83 | * @return \SpotifyApiConnect\Domain\DataTransferObject\ExternalUrlDataProvider |
||
| 84 | */ |
||
| 85 | public function getExternal_urls(): ?\SpotifyApiConnect\Domain\DataTransferObject\ExternalUrlDataProvider |
||
| 86 | { |
||
| 87 | return $this->external_urls; |
||
| 88 | } |
||
| 89 | |||
| 90 | |||
| 91 | /** |
||
| 92 | * @param \SpotifyApiConnect\Domain\DataTransferObject\ExternalUrlDataProvider $external_urls |
||
| 93 | * @return PlaylistDataProvider |
||
| 94 | */ |
||
| 95 | public function setExternal_urls(?\SpotifyApiConnect\Domain\DataTransferObject\ExternalUrlDataProvider $external_urls = null) |
||
| 96 | { |
||
| 97 | $this->external_urls = $external_urls; |
||
| 98 | |||
| 99 | return $this; |
||
| 100 | } |
||
| 101 | |||
| 102 | |||
| 103 | /** |
||
| 104 | * @return PlaylistDataProvider |
||
| 105 | */ |
||
| 106 | public function unsetExternal_urls() |
||
| 107 | { |
||
| 108 | $this->external_urls = null; |
||
| 109 | |||
| 110 | return $this; |
||
| 111 | } |
||
| 112 | |||
| 113 | |||
| 114 | /** |
||
| 115 | * @return bool |
||
| 116 | */ |
||
| 117 | public function hasExternal_urls() |
||
| 118 | { |
||
| 119 | return ($this->external_urls !== null && $this->external_urls !== []); |
||
| 120 | } |
||
| 121 | |||
| 122 | |||
| 123 | /** |
||
| 124 | * @return \SpotifyApiConnect\Domain\DataTransferObject\FollowersDataProvider |
||
| 125 | */ |
||
| 126 | public function getFollowers(): ?\SpotifyApiConnect\Domain\DataTransferObject\FollowersDataProvider |
||
| 127 | { |
||
| 128 | return $this->followers; |
||
| 129 | } |
||
| 130 | |||
| 131 | |||
| 132 | /** |
||
| 133 | * @param \SpotifyApiConnect\Domain\DataTransferObject\FollowersDataProvider $followers |
||
| 134 | * @return PlaylistDataProvider |
||
| 135 | */ |
||
| 136 | public function setFollowers(?\SpotifyApiConnect\Domain\DataTransferObject\FollowersDataProvider $followers = null) |
||
| 137 | { |
||
| 138 | $this->followers = $followers; |
||
| 139 | |||
| 140 | return $this; |
||
| 141 | } |
||
| 142 | |||
| 143 | |||
| 144 | /** |
||
| 145 | * @return PlaylistDataProvider |
||
| 146 | */ |
||
| 147 | public function unsetFollowers() |
||
| 148 | { |
||
| 149 | $this->followers = null; |
||
| 150 | |||
| 151 | return $this; |
||
| 152 | } |
||
| 153 | |||
| 154 | |||
| 155 | /** |
||
| 156 | * @return bool |
||
| 157 | */ |
||
| 158 | public function hasFollowers() |
||
| 159 | { |
||
| 160 | return ($this->followers !== null && $this->followers !== []); |
||
| 161 | } |
||
| 162 | |||
| 163 | |||
| 164 | /** |
||
| 165 | * @return string |
||
| 166 | */ |
||
| 167 | public function getId(): ?string |
||
| 168 | { |
||
| 169 | return $this->id; |
||
| 170 | } |
||
| 171 | |||
| 172 | |||
| 173 | /** |
||
| 174 | * @param string $id |
||
| 175 | * @return PlaylistDataProvider |
||
| 176 | */ |
||
| 177 | public function setId(?string $id = null) |
||
| 178 | { |
||
| 179 | $this->id = $id; |
||
| 180 | |||
| 181 | return $this; |
||
| 182 | } |
||
| 183 | |||
| 184 | |||
| 185 | /** |
||
| 186 | * @return PlaylistDataProvider |
||
| 187 | */ |
||
| 188 | public function unsetId() |
||
| 189 | { |
||
| 190 | $this->id = null; |
||
| 191 | |||
| 192 | return $this; |
||
| 193 | } |
||
| 194 | |||
| 195 | |||
| 196 | /** |
||
| 197 | * @return bool |
||
| 198 | */ |
||
| 199 | public function hasId() |
||
| 200 | { |
||
| 201 | return ($this->id !== null && $this->id !== []); |
||
| 202 | } |
||
| 203 | |||
| 204 | |||
| 205 | /** |
||
| 206 | * @return string |
||
| 207 | */ |
||
| 208 | public function getHref(): ?string |
||
| 209 | { |
||
| 210 | return $this->href; |
||
| 211 | } |
||
| 212 | |||
| 213 | |||
| 214 | /** |
||
| 215 | * @param string $href |
||
| 216 | * @return PlaylistDataProvider |
||
| 217 | */ |
||
| 218 | public function setHref(?string $href = null) |
||
| 219 | { |
||
| 220 | $this->href = $href; |
||
| 221 | |||
| 222 | return $this; |
||
| 223 | } |
||
| 224 | |||
| 225 | |||
| 226 | /** |
||
| 227 | * @return PlaylistDataProvider |
||
| 228 | */ |
||
| 229 | public function unsetHref() |
||
| 230 | { |
||
| 231 | $this->href = null; |
||
| 232 | |||
| 233 | return $this; |
||
| 234 | } |
||
| 235 | |||
| 236 | |||
| 237 | /** |
||
| 238 | * @return bool |
||
| 239 | */ |
||
| 240 | public function hasHref() |
||
| 241 | { |
||
| 242 | return ($this->href !== null && $this->href !== []); |
||
| 243 | } |
||
| 244 | |||
| 245 | |||
| 246 | /** |
||
| 247 | * @return string |
||
| 248 | */ |
||
| 249 | public function getName(): ?string |
||
| 250 | { |
||
| 251 | return $this->name; |
||
| 252 | } |
||
| 253 | |||
| 254 | |||
| 255 | /** |
||
| 256 | * @param string $name |
||
| 257 | * @return PlaylistDataProvider |
||
| 258 | */ |
||
| 259 | public function setName(?string $name = null) |
||
| 260 | { |
||
| 261 | $this->name = $name; |
||
| 262 | |||
| 263 | return $this; |
||
| 264 | } |
||
| 265 | |||
| 266 | |||
| 267 | /** |
||
| 268 | * @return PlaylistDataProvider |
||
| 269 | */ |
||
| 270 | public function unsetName() |
||
| 271 | { |
||
| 272 | $this->name = null; |
||
| 273 | |||
| 274 | return $this; |
||
| 275 | } |
||
| 276 | |||
| 277 | |||
| 278 | /** |
||
| 279 | * @return bool |
||
| 280 | */ |
||
| 281 | public function hasName() |
||
| 282 | { |
||
| 283 | return ($this->name !== null && $this->name !== []); |
||
| 284 | } |
||
| 285 | |||
| 286 | |||
| 287 | /** |
||
| 288 | * @return bool |
||
| 289 | */ |
||
| 290 | public function getPublic(): ?bool |
||
| 291 | { |
||
| 292 | return $this->public; |
||
| 293 | } |
||
| 294 | |||
| 295 | |||
| 296 | /** |
||
| 297 | * @param bool $public |
||
| 298 | * @return PlaylistDataProvider |
||
| 299 | */ |
||
| 300 | public function setPublic(?bool $public = null) |
||
| 301 | { |
||
| 302 | $this->public = $public; |
||
| 303 | |||
| 304 | return $this; |
||
| 305 | } |
||
| 306 | |||
| 307 | |||
| 308 | /** |
||
| 309 | * @return PlaylistDataProvider |
||
| 310 | */ |
||
| 311 | public function unsetPublic() |
||
| 312 | { |
||
| 313 | $this->public = null; |
||
| 314 | |||
| 315 | return $this; |
||
| 316 | } |
||
| 317 | |||
| 318 | |||
| 319 | /** |
||
| 320 | * @return bool |
||
| 321 | */ |
||
| 322 | public function hasPublic() |
||
| 323 | { |
||
| 324 | return ($this->public !== null && $this->public !== []); |
||
| 325 | } |
||
| 326 | |||
| 327 | |||
| 328 | /** |
||
| 329 | * @return \SpotifyApiConnect\Domain\DataTransferObject\PlaylistTracksDataProvider |
||
| 330 | */ |
||
| 331 | public function getTracks(): ?\SpotifyApiConnect\Domain\DataTransferObject\PlaylistTracksDataProvider |
||
| 332 | { |
||
| 333 | return $this->tracks; |
||
| 334 | } |
||
| 335 | |||
| 336 | |||
| 337 | /** |
||
| 338 | * @param \SpotifyApiConnect\Domain\DataTransferObject\PlaylistTracksDataProvider $tracks |
||
| 339 | * @return PlaylistDataProvider |
||
| 340 | */ |
||
| 341 | public function setTracks(?\SpotifyApiConnect\Domain\DataTransferObject\PlaylistTracksDataProvider $tracks = null) |
||
| 342 | { |
||
| 343 | $this->tracks = $tracks; |
||
| 344 | |||
| 345 | return $this; |
||
| 346 | } |
||
| 347 | |||
| 348 | |||
| 349 | /** |
||
| 350 | * @return PlaylistDataProvider |
||
| 351 | */ |
||
| 352 | public function unsetTracks() |
||
| 353 | { |
||
| 354 | $this->tracks = null; |
||
| 355 | |||
| 356 | return $this; |
||
| 357 | } |
||
| 358 | |||
| 359 | |||
| 360 | /** |
||
| 361 | * @return bool |
||
| 362 | */ |
||
| 363 | public function hasTracks() |
||
| 364 | { |
||
| 365 | return ($this->tracks !== null && $this->tracks !== []); |
||
| 366 | } |
||
| 367 | |||
| 368 | |||
| 369 | /** |
||
| 370 | * @param \SpotifyApiConnect\Domain\DataTransferObject\PlaylistTracksDataProvider $track |
||
| 371 | * @return PlaylistDataProvider |
||
| 372 | */ |
||
| 373 | public function addtrack(PlaylistTracksDataProvider $track) |
||
| 374 | { |
||
| 375 | $this->tracks[] = $track; return $this; |
||
| 376 | } |
||
| 377 | |||
| 378 | |||
| 379 | /** |
||
| 380 | * @return string |
||
| 381 | */ |
||
| 382 | public function getType(): ?string |
||
| 383 | { |
||
| 384 | return $this->type; |
||
| 385 | } |
||
| 386 | |||
| 387 | |||
| 388 | /** |
||
| 389 | * @param string $type |
||
| 390 | * @return PlaylistDataProvider |
||
| 391 | */ |
||
| 392 | public function setType(?string $type = null) |
||
| 393 | { |
||
| 394 | $this->type = $type; |
||
| 395 | |||
| 396 | return $this; |
||
| 397 | } |
||
| 398 | |||
| 399 | |||
| 400 | /** |
||
| 401 | * @return PlaylistDataProvider |
||
| 402 | */ |
||
| 403 | public function unsetType() |
||
| 404 | { |
||
| 405 | $this->type = null; |
||
| 406 | |||
| 407 | return $this; |
||
| 408 | } |
||
| 409 | |||
| 410 | |||
| 411 | /** |
||
| 412 | * @return bool |
||
| 413 | */ |
||
| 414 | public function hasType() |
||
| 415 | { |
||
| 416 | return ($this->type !== null && $this->type !== []); |
||
| 417 | } |
||
| 418 | |||
| 419 | |||
| 420 | /** |
||
| 421 | * @return string |
||
| 422 | */ |
||
| 423 | public function getUri(): ?string |
||
| 424 | { |
||
| 425 | return $this->uri; |
||
| 426 | } |
||
| 427 | |||
| 428 | |||
| 429 | /** |
||
| 430 | * @param string $uri |
||
| 431 | * @return PlaylistDataProvider |
||
| 432 | */ |
||
| 433 | public function setUri(?string $uri = null) |
||
| 434 | { |
||
| 435 | $this->uri = $uri; |
||
| 436 | |||
| 437 | return $this; |
||
| 438 | } |
||
| 439 | |||
| 440 | |||
| 441 | /** |
||
| 442 | * @return PlaylistDataProvider |
||
| 443 | */ |
||
| 444 | public function unsetUri() |
||
| 445 | { |
||
| 446 | $this->uri = null; |
||
| 447 | |||
| 448 | return $this; |
||
| 449 | } |
||
| 450 | |||
| 451 | |||
| 452 | /** |
||
| 453 | * @return bool |
||
| 454 | */ |
||
| 455 | public function hasUri() |
||
| 456 | { |
||
| 457 | return ($this->uri !== null && $this->uri !== []); |
||
| 458 | } |
||
| 459 | |||
| 460 | |||
| 461 | /** |
||
| 462 | * @return array |
||
| 463 | */ |
||
| 464 | protected function getElements(): array |
||
| 465 | { |
||
| 466 | return array ( |
||
| 467 | 'description' => |
||
| 468 | array ( |
||
| 469 | 'name' => 'description', |
||
| 470 | 'allownull' => true, |
||
| 471 | 'default' => '', |
||
| 472 | 'type' => 'string', |
||
| 473 | 'is_collection' => false, |
||
| 474 | 'is_dataprovider' => false, |
||
| 475 | 'isCamelCase' => false, |
||
| 476 | ), |
||
| 477 | 'external_urls' => |
||
| 478 | array ( |
||
| 479 | 'name' => 'external_urls', |
||
| 480 | 'allownull' => true, |
||
| 481 | 'default' => '', |
||
| 482 | 'type' => '\\SpotifyApiConnect\\Domain\\DataTransferObject\\ExternalUrlDataProvider', |
||
| 483 | 'is_collection' => false, |
||
| 484 | 'is_dataprovider' => true, |
||
| 485 | 'isCamelCase' => false, |
||
| 486 | ), |
||
| 487 | 'followers' => |
||
| 488 | array ( |
||
| 489 | 'name' => 'followers', |
||
| 490 | 'allownull' => true, |
||
| 491 | 'default' => '', |
||
| 492 | 'type' => '\\SpotifyApiConnect\\Domain\\DataTransferObject\\FollowersDataProvider', |
||
| 493 | 'is_collection' => false, |
||
| 494 | 'is_dataprovider' => true, |
||
| 495 | 'isCamelCase' => false, |
||
| 496 | ), |
||
| 497 | 'id' => |
||
| 498 | array ( |
||
| 499 | 'name' => 'id', |
||
| 500 | 'allownull' => true, |
||
| 501 | 'default' => '', |
||
| 502 | 'type' => 'string', |
||
| 503 | 'is_collection' => false, |
||
| 504 | 'is_dataprovider' => false, |
||
| 505 | 'isCamelCase' => false, |
||
| 506 | ), |
||
| 507 | 'href' => |
||
| 508 | array ( |
||
| 509 | 'name' => 'href', |
||
| 510 | 'allownull' => true, |
||
| 511 | 'default' => '', |
||
| 512 | 'type' => 'string', |
||
| 513 | 'is_collection' => false, |
||
| 514 | 'is_dataprovider' => false, |
||
| 515 | 'isCamelCase' => false, |
||
| 516 | ), |
||
| 517 | 'name' => |
||
| 518 | array ( |
||
| 519 | 'name' => 'name', |
||
| 520 | 'allownull' => true, |
||
| 521 | 'default' => '', |
||
| 522 | 'type' => 'string', |
||
| 523 | 'is_collection' => false, |
||
| 524 | 'is_dataprovider' => false, |
||
| 525 | 'isCamelCase' => false, |
||
| 526 | ), |
||
| 527 | 'public' => |
||
| 528 | array ( |
||
| 529 | 'name' => 'public', |
||
| 530 | 'allownull' => true, |
||
| 531 | 'default' => '', |
||
| 532 | 'type' => 'bool', |
||
| 533 | 'is_collection' => false, |
||
| 534 | 'is_dataprovider' => false, |
||
| 535 | 'isCamelCase' => false, |
||
| 536 | ), |
||
| 537 | 'tracks' => |
||
| 538 | array ( |
||
| 539 | 'name' => 'tracks', |
||
| 540 | 'allownull' => true, |
||
| 541 | 'default' => '', |
||
| 542 | 'type' => '\\SpotifyApiConnect\\Domain\\DataTransferObject\\PlaylistTracksDataProvider', |
||
| 543 | 'is_collection' => false, |
||
| 544 | 'is_dataprovider' => true, |
||
| 545 | 'isCamelCase' => false, |
||
| 546 | 'singleton' => 'track', |
||
| 547 | 'singleton_type' => '\\SpotifyApiConnect\\Domain\\DataTransferObject\\PlaylistTracksDataProvider', |
||
| 548 | ), |
||
| 549 | 'type' => |
||
| 550 | array ( |
||
| 551 | 'name' => 'type', |
||
| 552 | 'allownull' => true, |
||
| 553 | 'default' => '', |
||
| 554 | 'type' => 'string', |
||
| 555 | 'is_collection' => false, |
||
| 556 | 'is_dataprovider' => false, |
||
| 557 | 'isCamelCase' => false, |
||
| 558 | ), |
||
| 559 | 'uri' => |
||
| 560 | array ( |
||
| 561 | 'name' => 'uri', |
||
| 562 | 'allownull' => true, |
||
| 563 | 'default' => '', |
||
| 564 | 'type' => 'string', |
||
| 565 | 'is_collection' => false, |
||
| 566 | 'is_dataprovider' => false, |
||
| 567 | 'isCamelCase' => false, |
||
| 568 | ), |
||
| 572 |