| Total Complexity | 47 |
| Total Lines | 289 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like GetAccessPermissionDetailsResponseDetailsType 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 GetAccessPermissionDetailsResponseDetailsType, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 12 | class GetAccessPermissionDetailsResponseDetailsType extends AbstractStructBase |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The FirstName |
||
| 16 | * Meta information extracted from the WSDL |
||
| 17 | * - documentation: The first name of the User. Character length and limitations: 127 single-byte alphanumeric characters |
||
| 18 | * - minOccurs: 0 |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | public $FirstName; |
||
| 22 | /** |
||
| 23 | * The LastName |
||
| 24 | * Meta information extracted from the WSDL |
||
| 25 | * - documentation: The Last name of the user. Character length and limitations: 127 single-byte alphanumeric characters |
||
| 26 | * - minOccurs: 0 |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | public $LastName; |
||
| 30 | /** |
||
| 31 | * The Email |
||
| 32 | * Meta information extracted from the WSDL |
||
| 33 | * - documentation: The email address of the user. Character length and limitations: 256 single-byte alphanumeric characters. |
||
| 34 | * - minOccurs: 0 |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | public $Email; |
||
| 38 | /** |
||
| 39 | * The AccessPermissionName |
||
| 40 | * Meta information extracted from the WSDL |
||
| 41 | * - documentation: contains information about API Services |
||
| 42 | * - maxOccurs: unbounded |
||
| 43 | * - minOccurs: 0 |
||
| 44 | * @var string[] |
||
| 45 | */ |
||
| 46 | public $AccessPermissionName; |
||
| 47 | /** |
||
| 48 | * The AccessPermissionStatus |
||
| 49 | * Meta information extracted from the WSDL |
||
| 50 | * - documentation: contains information about API Services |
||
| 51 | * - maxOccurs: unbounded |
||
| 52 | * - minOccurs: 0 |
||
| 53 | * @var string[] |
||
| 54 | */ |
||
| 55 | public $AccessPermissionStatus; |
||
| 56 | /** |
||
| 57 | * The PayerID |
||
| 58 | * Meta information extracted from the WSDL |
||
| 59 | * - documentation: Encrypted PayPal customer account identification number. Required Character length and limitations: 127 single-byte characters. |
||
| 60 | * - base: xs:string |
||
| 61 | * - maxLength: 127 |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | public $PayerID; |
||
| 65 | /** |
||
| 66 | * Constructor method for GetAccessPermissionDetailsResponseDetailsType |
||
| 67 | * @uses GetAccessPermissionDetailsResponseDetailsType::setFirstName() |
||
| 68 | * @uses GetAccessPermissionDetailsResponseDetailsType::setLastName() |
||
| 69 | * @uses GetAccessPermissionDetailsResponseDetailsType::setEmail() |
||
| 70 | * @uses GetAccessPermissionDetailsResponseDetailsType::setAccessPermissionName() |
||
| 71 | * @uses GetAccessPermissionDetailsResponseDetailsType::setAccessPermissionStatus() |
||
| 72 | * @uses GetAccessPermissionDetailsResponseDetailsType::setPayerID() |
||
| 73 | * @param string $firstName |
||
| 74 | * @param string $lastName |
||
| 75 | * @param string $email |
||
| 76 | * @param string[] $accessPermissionName |
||
| 77 | * @param string[] $accessPermissionStatus |
||
| 78 | * @param string $payerID |
||
| 79 | */ |
||
| 80 | public function __construct($firstName = null, $lastName = null, $email = null, array $accessPermissionName = array(), array $accessPermissionStatus = array(), $payerID = null) |
||
| 81 | { |
||
| 82 | $this |
||
| 83 | ->setFirstName($firstName) |
||
| 84 | ->setLastName($lastName) |
||
| 85 | ->setEmail($email) |
||
| 86 | ->setAccessPermissionName($accessPermissionName) |
||
| 87 | ->setAccessPermissionStatus($accessPermissionStatus) |
||
| 88 | ->setPayerID($payerID); |
||
| 89 | } |
||
| 90 | /** |
||
| 91 | * Get FirstName value |
||
| 92 | * @return string|null |
||
| 93 | */ |
||
| 94 | public function getFirstName() |
||
| 95 | { |
||
| 96 | return $this->FirstName; |
||
| 97 | } |
||
| 98 | /** |
||
| 99 | * Set FirstName value |
||
| 100 | * @param string $firstName |
||
| 101 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 102 | */ |
||
| 103 | public function setFirstName($firstName = null) |
||
| 104 | { |
||
| 105 | // validation for constraint: string |
||
| 106 | if (!is_null($firstName) && !is_string($firstName)) { |
||
|
|
|||
| 107 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($firstName, true), gettype($firstName)), __LINE__); |
||
| 108 | } |
||
| 109 | $this->FirstName = $firstName; |
||
| 110 | return $this; |
||
| 111 | } |
||
| 112 | /** |
||
| 113 | * Get LastName value |
||
| 114 | * @return string|null |
||
| 115 | */ |
||
| 116 | public function getLastName() |
||
| 117 | { |
||
| 118 | return $this->LastName; |
||
| 119 | } |
||
| 120 | /** |
||
| 121 | * Set LastName value |
||
| 122 | * @param string $lastName |
||
| 123 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 124 | */ |
||
| 125 | public function setLastName($lastName = null) |
||
| 126 | { |
||
| 127 | // validation for constraint: string |
||
| 128 | if (!is_null($lastName) && !is_string($lastName)) { |
||
| 129 | throw new \InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($lastName, true), gettype($lastName)), __LINE__); |
||
| 130 | } |
||
| 131 | $this->LastName = $lastName; |
||
| 132 | return $this; |
||
| 133 | } |
||
| 134 | /** |
||
| 135 | * Get Email value |
||
| 136 | * @return string|null |
||
| 137 | */ |
||
| 138 | public function getEmail() |
||
| 139 | { |
||
| 140 | return $this->Email; |
||
| 141 | } |
||
| 142 | /** |
||
| 143 | * Set Email value |
||
| 144 | * @param string $email |
||
| 145 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 146 | */ |
||
| 147 | public function setEmail($email = null) |
||
| 155 | } |
||
| 156 | /** |
||
| 157 | * Get AccessPermissionName value |
||
| 158 | * @return string[]|null |
||
| 159 | */ |
||
| 160 | public function getAccessPermissionName() |
||
| 161 | { |
||
| 162 | return $this->AccessPermissionName; |
||
| 163 | } |
||
| 164 | /** |
||
| 165 | * This method is responsible for validating the values passed to the setAccessPermissionName method |
||
| 166 | * This method is willingly generated in order to preserve the one-line inline validation within the setAccessPermissionName method |
||
| 167 | * @param array $values |
||
| 168 | * @return string A non-empty message if the values does not match the validation rules |
||
| 169 | */ |
||
| 170 | public static function validateAccessPermissionNameForArrayConstraintsFromSetAccessPermissionName(array $values = array()) |
||
| 171 | { |
||
| 172 | $message = ''; |
||
| 173 | $invalidValues = []; |
||
| 174 | foreach ($values as $getAccessPermissionDetailsResponseDetailsTypeAccessPermissionNameItem) { |
||
| 175 | // validation for constraint: itemType |
||
| 176 | if (!is_string($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionNameItem)) { |
||
| 177 | $invalidValues[] = is_object($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionNameItem) ? get_class($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionNameItem) : sprintf('%s(%s)', gettype($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionNameItem), var_export($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionNameItem, true)); |
||
| 178 | } |
||
| 179 | } |
||
| 180 | if (!empty($invalidValues)) { |
||
| 181 | $message = sprintf('The AccessPermissionName property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
| 182 | } |
||
| 183 | unset($invalidValues); |
||
| 184 | return $message; |
||
| 185 | } |
||
| 186 | /** |
||
| 187 | * Set AccessPermissionName value |
||
| 188 | * @throws \InvalidArgumentException |
||
| 189 | * @param string[] $accessPermissionName |
||
| 190 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 191 | */ |
||
| 192 | public function setAccessPermissionName(array $accessPermissionName = array()) |
||
| 193 | { |
||
| 194 | // validation for constraint: array |
||
| 195 | if ('' !== ($accessPermissionNameArrayErrorMessage = self::validateAccessPermissionNameForArrayConstraintsFromSetAccessPermissionName($accessPermissionName))) { |
||
| 196 | throw new \InvalidArgumentException($accessPermissionNameArrayErrorMessage, __LINE__); |
||
| 197 | } |
||
| 198 | $this->AccessPermissionName = $accessPermissionName; |
||
| 199 | return $this; |
||
| 200 | } |
||
| 201 | /** |
||
| 202 | * Add item to AccessPermissionName value |
||
| 203 | * @throws \InvalidArgumentException |
||
| 204 | * @param string $item |
||
| 205 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 206 | */ |
||
| 207 | public function addToAccessPermissionName($item) |
||
| 208 | { |
||
| 209 | // validation for constraint: itemType |
||
| 210 | if (!is_string($item)) { |
||
| 211 | throw new \InvalidArgumentException(sprintf('The AccessPermissionName property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
| 212 | } |
||
| 213 | $this->AccessPermissionName[] = $item; |
||
| 214 | return $this; |
||
| 215 | } |
||
| 216 | /** |
||
| 217 | * Get AccessPermissionStatus value |
||
| 218 | * @return string[]|null |
||
| 219 | */ |
||
| 220 | public function getAccessPermissionStatus() |
||
| 223 | } |
||
| 224 | /** |
||
| 225 | * This method is responsible for validating the values passed to the setAccessPermissionStatus method |
||
| 226 | * This method is willingly generated in order to preserve the one-line inline validation within the setAccessPermissionStatus method |
||
| 227 | * @param array $values |
||
| 228 | * @return string A non-empty message if the values does not match the validation rules |
||
| 229 | */ |
||
| 230 | public static function validateAccessPermissionStatusForArrayConstraintsFromSetAccessPermissionStatus(array $values = array()) |
||
| 231 | { |
||
| 232 | $message = ''; |
||
| 233 | $invalidValues = []; |
||
| 234 | foreach ($values as $getAccessPermissionDetailsResponseDetailsTypeAccessPermissionStatusItem) { |
||
| 235 | // validation for constraint: itemType |
||
| 236 | if (!is_string($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionStatusItem)) { |
||
| 237 | $invalidValues[] = is_object($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionStatusItem) ? get_class($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionStatusItem) : sprintf('%s(%s)', gettype($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionStatusItem), var_export($getAccessPermissionDetailsResponseDetailsTypeAccessPermissionStatusItem, true)); |
||
| 238 | } |
||
| 239 | } |
||
| 240 | if (!empty($invalidValues)) { |
||
| 241 | $message = sprintf('The AccessPermissionStatus property can only contain items of type string, %s given', is_object($invalidValues) ? get_class($invalidValues) : (is_array($invalidValues) ? implode(', ', $invalidValues) : gettype($invalidValues))); |
||
| 242 | } |
||
| 243 | unset($invalidValues); |
||
| 244 | return $message; |
||
| 245 | } |
||
| 246 | /** |
||
| 247 | * Set AccessPermissionStatus value |
||
| 248 | * @throws \InvalidArgumentException |
||
| 249 | * @param string[] $accessPermissionStatus |
||
| 250 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 251 | */ |
||
| 252 | public function setAccessPermissionStatus(array $accessPermissionStatus = array()) |
||
| 253 | { |
||
| 254 | // validation for constraint: array |
||
| 255 | if ('' !== ($accessPermissionStatusArrayErrorMessage = self::validateAccessPermissionStatusForArrayConstraintsFromSetAccessPermissionStatus($accessPermissionStatus))) { |
||
| 256 | throw new \InvalidArgumentException($accessPermissionStatusArrayErrorMessage, __LINE__); |
||
| 257 | } |
||
| 258 | $this->AccessPermissionStatus = $accessPermissionStatus; |
||
| 259 | return $this; |
||
| 260 | } |
||
| 261 | /** |
||
| 262 | * Add item to AccessPermissionStatus value |
||
| 263 | * @throws \InvalidArgumentException |
||
| 264 | * @param string $item |
||
| 265 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 266 | */ |
||
| 267 | public function addToAccessPermissionStatus($item) |
||
| 268 | { |
||
| 269 | // validation for constraint: itemType |
||
| 270 | if (!is_string($item)) { |
||
| 271 | throw new \InvalidArgumentException(sprintf('The AccessPermissionStatus property can only contain items of type string, %s given', is_object($item) ? get_class($item) : (is_array($item) ? implode(', ', $item) : gettype($item))), __LINE__); |
||
| 272 | } |
||
| 273 | $this->AccessPermissionStatus[] = $item; |
||
| 274 | return $this; |
||
| 275 | } |
||
| 276 | /** |
||
| 277 | * Get PayerID value |
||
| 278 | * @return string|null |
||
| 279 | */ |
||
| 280 | public function getPayerID() |
||
| 283 | } |
||
| 284 | /** |
||
| 285 | * Set PayerID value |
||
| 286 | * @param string $payerID |
||
| 287 | * @return \PayPal\StructType\GetAccessPermissionDetailsResponseDetailsType |
||
| 288 | */ |
||
| 289 | public function setPayerID($payerID = null) |
||
| 301 | } |
||
| 302 | } |
||
| 303 |