| Total Complexity | 61 |
| Total Lines | 378 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like EwsSetFolderFieldType 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 EwsSetFolderFieldType, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 16 | class EwsSetFolderFieldType extends EwsFolderChangeDescriptionType |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * The Folder |
||
| 20 | * Meta information extracted from the WSDL |
||
| 21 | * - choice: Folder | CalendarFolder | ContactsFolder | SearchFolder | TasksFolder |
||
| 22 | * - choiceMaxOccurs: 1 |
||
| 23 | * - choiceMinOccurs: 1 |
||
| 24 | * @var \StructType\EwsFolderType|null |
||
| 25 | */ |
||
| 26 | protected ?\StructType\EwsFolderType $Folder = null; |
||
| 27 | /** |
||
| 28 | * The CalendarFolder |
||
| 29 | * Meta information extracted from the WSDL |
||
| 30 | * - choice: Folder | CalendarFolder | ContactsFolder | SearchFolder | TasksFolder |
||
| 31 | * - choiceMaxOccurs: 1 |
||
| 32 | * - choiceMinOccurs: 1 |
||
| 33 | * @var \StructType\EwsCalendarFolderType|null |
||
| 34 | */ |
||
| 35 | protected ?\StructType\EwsCalendarFolderType $CalendarFolder = null; |
||
| 36 | /** |
||
| 37 | * The ContactsFolder |
||
| 38 | * Meta information extracted from the WSDL |
||
| 39 | * - choice: Folder | CalendarFolder | ContactsFolder | SearchFolder | TasksFolder |
||
| 40 | * - choiceMaxOccurs: 1 |
||
| 41 | * - choiceMinOccurs: 1 |
||
| 42 | * @var \StructType\EwsContactsFolderType|null |
||
| 43 | */ |
||
| 44 | protected ?\StructType\EwsContactsFolderType $ContactsFolder = null; |
||
| 45 | /** |
||
| 46 | * The SearchFolder |
||
| 47 | * Meta information extracted from the WSDL |
||
| 48 | * - choice: Folder | CalendarFolder | ContactsFolder | SearchFolder | TasksFolder |
||
| 49 | * - choiceMaxOccurs: 1 |
||
| 50 | * - choiceMinOccurs: 1 |
||
| 51 | * @var \StructType\EwsSearchFolderType|null |
||
| 52 | */ |
||
| 53 | protected ?\StructType\EwsSearchFolderType $SearchFolder = null; |
||
| 54 | /** |
||
| 55 | * The TasksFolder |
||
| 56 | * Meta information extracted from the WSDL |
||
| 57 | * - choice: Folder | CalendarFolder | ContactsFolder | SearchFolder | TasksFolder |
||
| 58 | * - choiceMaxOccurs: 1 |
||
| 59 | * - choiceMinOccurs: 1 |
||
| 60 | * @var \StructType\EwsTasksFolderType|null |
||
| 61 | */ |
||
| 62 | protected ?\StructType\EwsTasksFolderType $TasksFolder = null; |
||
| 63 | /** |
||
| 64 | * Constructor method for SetFolderFieldType |
||
| 65 | * @uses EwsSetFolderFieldType::setFolder() |
||
| 66 | * @uses EwsSetFolderFieldType::setCalendarFolder() |
||
| 67 | * @uses EwsSetFolderFieldType::setContactsFolder() |
||
| 68 | * @uses EwsSetFolderFieldType::setSearchFolder() |
||
| 69 | * @uses EwsSetFolderFieldType::setTasksFolder() |
||
| 70 | * @param \StructType\EwsFolderType $folder |
||
| 71 | * @param \StructType\EwsCalendarFolderType $calendarFolder |
||
| 72 | * @param \StructType\EwsContactsFolderType $contactsFolder |
||
| 73 | * @param \StructType\EwsSearchFolderType $searchFolder |
||
| 74 | * @param \StructType\EwsTasksFolderType $tasksFolder |
||
| 75 | */ |
||
| 76 | public function __construct(?\StructType\EwsFolderType $folder = null, ?\StructType\EwsCalendarFolderType $calendarFolder = null, ?\StructType\EwsContactsFolderType $contactsFolder = null, ?\StructType\EwsSearchFolderType $searchFolder = null, ?\StructType\EwsTasksFolderType $tasksFolder = null) |
||
| 77 | { |
||
| 78 | $this |
||
| 79 | ->setFolder($folder) |
||
| 80 | ->setCalendarFolder($calendarFolder) |
||
| 81 | ->setContactsFolder($contactsFolder) |
||
| 82 | ->setSearchFolder($searchFolder) |
||
| 83 | ->setTasksFolder($tasksFolder); |
||
| 84 | } |
||
| 85 | /** |
||
| 86 | * Get Folder value |
||
| 87 | * @return \StructType\EwsFolderType|null |
||
| 88 | */ |
||
| 89 | public function getFolder(): ?\StructType\EwsFolderType |
||
| 90 | { |
||
| 91 | return isset($this->Folder) ? $this->Folder : null; |
||
| 92 | } |
||
| 93 | /** |
||
| 94 | * This method is responsible for validating the value passed to the setFolder method |
||
| 95 | * This method is willingly generated in order to preserve the one-line inline validation within the setFolder method |
||
| 96 | * This has to validate that the property which is being set is the only one among the given choices |
||
| 97 | * @param mixed $value |
||
| 98 | * @return string A non-empty message if the values does not match the validation rules |
||
| 99 | */ |
||
| 100 | public function validateFolderForChoiceConstraintsFromSetFolder($value): string |
||
| 101 | { |
||
| 102 | $message = ''; |
||
| 103 | if (is_null($value)) { |
||
| 104 | return $message; |
||
| 105 | } |
||
| 106 | $properties = [ |
||
| 107 | 'CalendarFolder', |
||
| 108 | 'ContactsFolder', |
||
| 109 | 'SearchFolder', |
||
| 110 | 'TasksFolder', |
||
| 111 | ]; |
||
| 112 | try { |
||
| 113 | foreach ($properties as $property) { |
||
| 114 | if (isset($this->{$property})) { |
||
| 115 | throw new InvalidArgumentException(sprintf('The property Folder can\'t be set as the property %s is already set. Only one property must be set among these properties: Folder, %s.', $property, implode(', ', $properties)), __LINE__); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | } catch (InvalidArgumentException $e) { |
||
| 119 | $message = $e->getMessage(); |
||
| 120 | } |
||
| 121 | |||
| 122 | return $message; |
||
| 123 | } |
||
| 124 | /** |
||
| 125 | * Set Folder value |
||
| 126 | * This property belongs to a choice that allows only one property to exist. It is |
||
| 127 | * therefore removable from the request, consequently if the value assigned to this |
||
| 128 | * property is null, the property is removed from this object |
||
| 129 | * @throws InvalidArgumentException |
||
| 130 | * @param \StructType\EwsFolderType $folder |
||
| 131 | * @return \StructType\EwsSetFolderFieldType |
||
| 132 | */ |
||
| 133 | public function setFolder(?\StructType\EwsFolderType $folder = null): self |
||
| 134 | { |
||
| 135 | // validation for constraint: choice(Folder, CalendarFolder, ContactsFolder, SearchFolder, TasksFolder) |
||
| 136 | if ('' !== ($folderChoiceErrorMessage = self::validateFolderForChoiceConstraintsFromSetFolder($folder))) { |
||
|
|
|||
| 137 | throw new InvalidArgumentException($folderChoiceErrorMessage, __LINE__); |
||
| 138 | } |
||
| 139 | if (is_null($folder) || (is_array($folder) && empty($folder))) { |
||
| 140 | unset($this->Folder); |
||
| 141 | } else { |
||
| 142 | $this->Folder = $folder; |
||
| 143 | } |
||
| 144 | |||
| 145 | return $this; |
||
| 146 | } |
||
| 147 | /** |
||
| 148 | * Get CalendarFolder value |
||
| 149 | * @return \StructType\EwsCalendarFolderType|null |
||
| 150 | */ |
||
| 151 | public function getCalendarFolder(): ?\StructType\EwsCalendarFolderType |
||
| 152 | { |
||
| 153 | return isset($this->CalendarFolder) ? $this->CalendarFolder : null; |
||
| 154 | } |
||
| 155 | /** |
||
| 156 | * This method is responsible for validating the value passed to the setCalendarFolder method |
||
| 157 | * This method is willingly generated in order to preserve the one-line inline validation within the setCalendarFolder method |
||
| 158 | * This has to validate that the property which is being set is the only one among the given choices |
||
| 159 | * @param mixed $value |
||
| 160 | * @return string A non-empty message if the values does not match the validation rules |
||
| 161 | */ |
||
| 162 | public function validateCalendarFolderForChoiceConstraintsFromSetCalendarFolder($value): string |
||
| 163 | { |
||
| 164 | $message = ''; |
||
| 165 | if (is_null($value)) { |
||
| 166 | return $message; |
||
| 167 | } |
||
| 168 | $properties = [ |
||
| 169 | 'Folder', |
||
| 170 | 'ContactsFolder', |
||
| 171 | 'SearchFolder', |
||
| 172 | 'TasksFolder', |
||
| 173 | ]; |
||
| 174 | try { |
||
| 175 | foreach ($properties as $property) { |
||
| 176 | if (isset($this->{$property})) { |
||
| 177 | throw new InvalidArgumentException(sprintf('The property CalendarFolder can\'t be set as the property %s is already set. Only one property must be set among these properties: CalendarFolder, %s.', $property, implode(', ', $properties)), __LINE__); |
||
| 178 | } |
||
| 179 | } |
||
| 180 | } catch (InvalidArgumentException $e) { |
||
| 181 | $message = $e->getMessage(); |
||
| 182 | } |
||
| 183 | |||
| 184 | return $message; |
||
| 185 | } |
||
| 186 | /** |
||
| 187 | * Set CalendarFolder value |
||
| 188 | * This property belongs to a choice that allows only one property to exist. It is |
||
| 189 | * therefore removable from the request, consequently if the value assigned to this |
||
| 190 | * property is null, the property is removed from this object |
||
| 191 | * @throws InvalidArgumentException |
||
| 192 | * @param \StructType\EwsCalendarFolderType $calendarFolder |
||
| 193 | * @return \StructType\EwsSetFolderFieldType |
||
| 194 | */ |
||
| 195 | public function setCalendarFolder(?\StructType\EwsCalendarFolderType $calendarFolder = null): self |
||
| 196 | { |
||
| 197 | // validation for constraint: choice(Folder, CalendarFolder, ContactsFolder, SearchFolder, TasksFolder) |
||
| 198 | if ('' !== ($calendarFolderChoiceErrorMessage = self::validateCalendarFolderForChoiceConstraintsFromSetCalendarFolder($calendarFolder))) { |
||
| 199 | throw new InvalidArgumentException($calendarFolderChoiceErrorMessage, __LINE__); |
||
| 200 | } |
||
| 201 | if (is_null($calendarFolder) || (is_array($calendarFolder) && empty($calendarFolder))) { |
||
| 202 | unset($this->CalendarFolder); |
||
| 203 | } else { |
||
| 204 | $this->CalendarFolder = $calendarFolder; |
||
| 205 | } |
||
| 206 | |||
| 207 | return $this; |
||
| 208 | } |
||
| 209 | /** |
||
| 210 | * Get ContactsFolder value |
||
| 211 | * @return \StructType\EwsContactsFolderType|null |
||
| 212 | */ |
||
| 213 | public function getContactsFolder(): ?\StructType\EwsContactsFolderType |
||
| 214 | { |
||
| 215 | return isset($this->ContactsFolder) ? $this->ContactsFolder : null; |
||
| 216 | } |
||
| 217 | /** |
||
| 218 | * This method is responsible for validating the value passed to the setContactsFolder method |
||
| 219 | * This method is willingly generated in order to preserve the one-line inline validation within the setContactsFolder method |
||
| 220 | * This has to validate that the property which is being set is the only one among the given choices |
||
| 221 | * @param mixed $value |
||
| 222 | * @return string A non-empty message if the values does not match the validation rules |
||
| 223 | */ |
||
| 224 | public function validateContactsFolderForChoiceConstraintsFromSetContactsFolder($value): string |
||
| 247 | } |
||
| 248 | /** |
||
| 249 | * Set ContactsFolder value |
||
| 250 | * This property belongs to a choice that allows only one property to exist. It is |
||
| 251 | * therefore removable from the request, consequently if the value assigned to this |
||
| 252 | * property is null, the property is removed from this object |
||
| 253 | * @throws InvalidArgumentException |
||
| 254 | * @param \StructType\EwsContactsFolderType $contactsFolder |
||
| 255 | * @return \StructType\EwsSetFolderFieldType |
||
| 256 | */ |
||
| 257 | public function setContactsFolder(?\StructType\EwsContactsFolderType $contactsFolder = null): self |
||
| 258 | { |
||
| 259 | // validation for constraint: choice(Folder, CalendarFolder, ContactsFolder, SearchFolder, TasksFolder) |
||
| 260 | if ('' !== ($contactsFolderChoiceErrorMessage = self::validateContactsFolderForChoiceConstraintsFromSetContactsFolder($contactsFolder))) { |
||
| 261 | throw new InvalidArgumentException($contactsFolderChoiceErrorMessage, __LINE__); |
||
| 262 | } |
||
| 263 | if (is_null($contactsFolder) || (is_array($contactsFolder) && empty($contactsFolder))) { |
||
| 264 | unset($this->ContactsFolder); |
||
| 265 | } else { |
||
| 266 | $this->ContactsFolder = $contactsFolder; |
||
| 267 | } |
||
| 268 | |||
| 269 | return $this; |
||
| 270 | } |
||
| 271 | /** |
||
| 272 | * Get SearchFolder value |
||
| 273 | * @return \StructType\EwsSearchFolderType|null |
||
| 274 | */ |
||
| 275 | public function getSearchFolder(): ?\StructType\EwsSearchFolderType |
||
| 278 | } |
||
| 279 | /** |
||
| 280 | * This method is responsible for validating the value passed to the setSearchFolder method |
||
| 281 | * This method is willingly generated in order to preserve the one-line inline validation within the setSearchFolder method |
||
| 282 | * This has to validate that the property which is being set is the only one among the given choices |
||
| 283 | * @param mixed $value |
||
| 284 | * @return string A non-empty message if the values does not match the validation rules |
||
| 285 | */ |
||
| 286 | public function validateSearchFolderForChoiceConstraintsFromSetSearchFolder($value): string |
||
| 287 | { |
||
| 288 | $message = ''; |
||
| 289 | if (is_null($value)) { |
||
| 290 | return $message; |
||
| 291 | } |
||
| 292 | $properties = [ |
||
| 293 | 'Folder', |
||
| 294 | 'CalendarFolder', |
||
| 295 | 'ContactsFolder', |
||
| 296 | 'TasksFolder', |
||
| 297 | ]; |
||
| 298 | try { |
||
| 299 | foreach ($properties as $property) { |
||
| 300 | if (isset($this->{$property})) { |
||
| 301 | throw new InvalidArgumentException(sprintf('The property SearchFolder can\'t be set as the property %s is already set. Only one property must be set among these properties: SearchFolder, %s.', $property, implode(', ', $properties)), __LINE__); |
||
| 302 | } |
||
| 303 | } |
||
| 304 | } catch (InvalidArgumentException $e) { |
||
| 305 | $message = $e->getMessage(); |
||
| 306 | } |
||
| 307 | |||
| 308 | return $message; |
||
| 309 | } |
||
| 310 | /** |
||
| 311 | * Set SearchFolder value |
||
| 312 | * This property belongs to a choice that allows only one property to exist. It is |
||
| 313 | * therefore removable from the request, consequently if the value assigned to this |
||
| 314 | * property is null, the property is removed from this object |
||
| 315 | * @throws InvalidArgumentException |
||
| 316 | * @param \StructType\EwsSearchFolderType $searchFolder |
||
| 317 | * @return \StructType\EwsSetFolderFieldType |
||
| 318 | */ |
||
| 319 | public function setSearchFolder(?\StructType\EwsSearchFolderType $searchFolder = null): self |
||
| 320 | { |
||
| 321 | // validation for constraint: choice(Folder, CalendarFolder, ContactsFolder, SearchFolder, TasksFolder) |
||
| 322 | if ('' !== ($searchFolderChoiceErrorMessage = self::validateSearchFolderForChoiceConstraintsFromSetSearchFolder($searchFolder))) { |
||
| 323 | throw new InvalidArgumentException($searchFolderChoiceErrorMessage, __LINE__); |
||
| 324 | } |
||
| 325 | if (is_null($searchFolder) || (is_array($searchFolder) && empty($searchFolder))) { |
||
| 326 | unset($this->SearchFolder); |
||
| 327 | } else { |
||
| 328 | $this->SearchFolder = $searchFolder; |
||
| 329 | } |
||
| 330 | |||
| 331 | return $this; |
||
| 332 | } |
||
| 333 | /** |
||
| 334 | * Get TasksFolder value |
||
| 335 | * @return \StructType\EwsTasksFolderType|null |
||
| 336 | */ |
||
| 337 | public function getTasksFolder(): ?\StructType\EwsTasksFolderType |
||
| 338 | { |
||
| 339 | return isset($this->TasksFolder) ? $this->TasksFolder : null; |
||
| 340 | } |
||
| 341 | /** |
||
| 342 | * This method is responsible for validating the value passed to the setTasksFolder method |
||
| 343 | * This method is willingly generated in order to preserve the one-line inline validation within the setTasksFolder method |
||
| 344 | * This has to validate that the property which is being set is the only one among the given choices |
||
| 345 | * @param mixed $value |
||
| 346 | * @return string A non-empty message if the values does not match the validation rules |
||
| 347 | */ |
||
| 348 | public function validateTasksFolderForChoiceConstraintsFromSetTasksFolder($value): string |
||
| 349 | { |
||
| 350 | $message = ''; |
||
| 351 | if (is_null($value)) { |
||
| 352 | return $message; |
||
| 353 | } |
||
| 354 | $properties = [ |
||
| 355 | 'Folder', |
||
| 356 | 'CalendarFolder', |
||
| 357 | 'ContactsFolder', |
||
| 358 | 'SearchFolder', |
||
| 359 | ]; |
||
| 360 | try { |
||
| 361 | foreach ($properties as $property) { |
||
| 362 | if (isset($this->{$property})) { |
||
| 363 | throw new InvalidArgumentException(sprintf('The property TasksFolder can\'t be set as the property %s is already set. Only one property must be set among these properties: TasksFolder, %s.', $property, implode(', ', $properties)), __LINE__); |
||
| 364 | } |
||
| 365 | } |
||
| 366 | } catch (InvalidArgumentException $e) { |
||
| 367 | $message = $e->getMessage(); |
||
| 368 | } |
||
| 369 | |||
| 370 | return $message; |
||
| 371 | } |
||
| 372 | /** |
||
| 373 | * Set TasksFolder value |
||
| 374 | * This property belongs to a choice that allows only one property to exist. It is |
||
| 375 | * therefore removable from the request, consequently if the value assigned to this |
||
| 376 | * property is null, the property is removed from this object |
||
| 377 | * @throws InvalidArgumentException |
||
| 378 | * @param \StructType\EwsTasksFolderType $tasksFolder |
||
| 379 | * @return \StructType\EwsSetFolderFieldType |
||
| 380 | */ |
||
| 381 | public function setTasksFolder(?\StructType\EwsTasksFolderType $tasksFolder = null): self |
||
| 394 | } |
||
| 395 | } |
||
| 396 |