| Total Complexity | 42 |
| Total Lines | 274 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like ApplicationParameters 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 ApplicationParameters, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | final class ApplicationParameters |
||
| 8 | { |
||
| 9 | private string $brandUrl; |
||
| 10 | private string $charset; |
||
| 11 | private array $heroOptions = []; |
||
| 12 | private array $heroHeadOptions = []; |
||
| 13 | private array $heroBodyOptions = []; |
||
| 14 | private array $heroContainerOptions = []; |
||
| 15 | private array $heroFooterOptions = []; |
||
| 16 | private array $heroFooterColumnOptions = []; |
||
| 17 | private string $heroFooterColumnCenter; |
||
| 18 | private array $heroFooterColumnCenterOptions = []; |
||
| 19 | private string $heroFooterColumnLeft; |
||
| 20 | private array $heroFooterColumnLeftOptions = []; |
||
| 21 | private string $heroFooterColumnRight; |
||
| 22 | private array $heroFooterColumnRightOptions = []; |
||
| 23 | private string $language; |
||
| 24 | private string $logo; |
||
| 25 | private string $name; |
||
| 26 | private array $navBarOptions = []; |
||
| 27 | private array $navBarBrandOptions = []; |
||
| 28 | private array $navBarBrandLogoOptions = []; |
||
| 29 | private array $navBarBrandTitleOptions = []; |
||
| 30 | |||
| 31 | public function getBrandUrl(): string |
||
| 32 | { |
||
| 33 | return $this->brandUrl; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getCharset(): string |
||
| 37 | { |
||
| 38 | return $this->charset; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function getHeroOptions(): array |
||
| 42 | { |
||
| 43 | return $this->heroOptions; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function getHeroHeadOptions(): array |
||
| 47 | { |
||
| 48 | return $this->heroHeadOptions; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function getHeroContainerOptions(): array |
||
| 52 | { |
||
| 53 | return $this->heroContainerOptions; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function getHeroBodyOptions(): array |
||
| 57 | { |
||
| 58 | return $this->heroBodyOptions; |
||
| 59 | } |
||
| 60 | |||
| 61 | public function getHeroFooterOptions(): array |
||
| 62 | { |
||
| 63 | return $this->heroFooterOptions; |
||
| 64 | } |
||
| 65 | |||
| 66 | public function getHeroFooterColumnOptions(): array |
||
| 67 | { |
||
| 68 | return $this->heroFooterColumnOptions; |
||
| 69 | } |
||
| 70 | |||
| 71 | public function getHeroFooterColumnCenter(): string |
||
| 72 | { |
||
| 73 | return $this->heroFooterColumnCenter; |
||
| 74 | } |
||
| 75 | |||
| 76 | public function getHeroFooterColumnCenterOptions(): array |
||
| 77 | { |
||
| 78 | return $this->heroFooterColumnCenterOptions; |
||
| 79 | } |
||
| 80 | |||
| 81 | public function getHeroFooterColumnLeft(): string |
||
| 82 | { |
||
| 83 | return $this->heroFooterColumnLeft; |
||
| 84 | } |
||
| 85 | |||
| 86 | public function getHeroFooterColumnLeftOptions(): array |
||
| 87 | { |
||
| 88 | return $this->heroFooterColumnLeftOptions; |
||
| 89 | } |
||
| 90 | |||
| 91 | public function getHeroFooterColumnRight(): string |
||
| 92 | { |
||
| 93 | return $this->heroFooterColumnRight; |
||
| 94 | } |
||
| 95 | |||
| 96 | public function getHeroFooterColumnRightOptions(): array |
||
| 97 | { |
||
| 98 | return $this->heroFooterColumnRightOptions; |
||
| 99 | } |
||
| 100 | |||
| 101 | public function getLanguage(): string |
||
| 102 | { |
||
| 103 | return $this->language; |
||
| 104 | } |
||
| 105 | |||
| 106 | public function getLogo(): string |
||
| 107 | { |
||
| 108 | return $this->logo; |
||
| 109 | } |
||
| 110 | |||
| 111 | public function getNavBarOptions(): array |
||
| 112 | { |
||
| 113 | return $this->navBarOptions; |
||
| 114 | } |
||
| 115 | |||
| 116 | public function getNavBarBrandOptions(): array |
||
| 117 | { |
||
| 118 | return $this->navBarBrandOptions; |
||
| 119 | } |
||
| 120 | |||
| 121 | public function getNavBarBrandLogoOptions(): array |
||
| 122 | { |
||
| 123 | return $this->navBarBrandLogoOptions; |
||
| 124 | } |
||
| 125 | |||
| 126 | public function getNavBarBrandTitleOptions(): array |
||
| 127 | { |
||
| 128 | return $this->navBarBrandTitleOptions; |
||
| 129 | } |
||
| 130 | |||
| 131 | public function getName(): string |
||
| 132 | { |
||
| 133 | return $this->name; |
||
| 134 | } |
||
| 135 | |||
| 136 | public function brandUrl(string $value): self |
||
| 137 | { |
||
| 138 | $new = clone $this; |
||
| 139 | $new->brandUrl = $value; |
||
| 140 | return $new; |
||
| 141 | } |
||
| 142 | |||
| 143 | public function charset(string $value): self |
||
| 144 | { |
||
| 145 | $new = clone $this; |
||
| 146 | $new->charset = $value; |
||
| 147 | return $new; |
||
| 148 | } |
||
| 149 | |||
| 150 | public function heroOptions(array $value): self |
||
| 151 | { |
||
| 152 | $new = clone $this; |
||
| 153 | $new->heroOptions = $value; |
||
| 154 | return $new; |
||
| 155 | } |
||
| 156 | |||
| 157 | public function heroHeadOptions(array $value): self |
||
| 158 | { |
||
| 159 | $new = clone $this; |
||
| 160 | $new->heroHeadOptions = $value; |
||
| 161 | return $new; |
||
| 162 | } |
||
| 163 | |||
| 164 | public function heroContainerOptions(array $value): self |
||
| 165 | { |
||
| 166 | $new = clone $this; |
||
| 167 | $new->heroContainerOptions = $value; |
||
| 168 | return $new; |
||
| 169 | } |
||
| 170 | |||
| 171 | public function heroBodyOptions(array $value): self |
||
| 176 | } |
||
| 177 | |||
| 178 | public function heroFooterColumnOptions(array $value): self |
||
| 183 | } |
||
| 184 | |||
| 185 | public function heroFooterColumnCenter(string $value): self |
||
| 186 | { |
||
| 187 | $new = clone $this; |
||
| 188 | $new->heroFooterColumnCenter = $value; |
||
| 189 | return $new; |
||
| 190 | } |
||
| 191 | |||
| 192 | public function heroFooterColumnCenterOptions(array $value): self |
||
| 193 | { |
||
| 194 | $new = clone $this; |
||
| 195 | $new->heroFooterColumnCenterOptions = $value; |
||
| 196 | return $new; |
||
| 197 | } |
||
| 198 | |||
| 199 | public function heroFooterColumnLeft(string $value): self |
||
| 200 | { |
||
| 201 | $new = clone $this; |
||
| 202 | $new->heroFooterColumnLeft = $value; |
||
| 203 | return $new; |
||
| 204 | } |
||
| 205 | |||
| 206 | public function heroFooterColumnLeftOptions(array $value): self |
||
| 207 | { |
||
| 208 | $new = clone $this; |
||
| 209 | $new->heroFooterColumnLeftOptions = $value; |
||
| 210 | return $new; |
||
| 211 | } |
||
| 212 | |||
| 213 | public function heroFooterColumnRight(string $value): self |
||
| 214 | { |
||
| 215 | $new = clone $this; |
||
| 216 | $new->heroFooterColumnRight = $value; |
||
| 217 | return $new; |
||
| 218 | } |
||
| 219 | |||
| 220 | public function heroFooterColumnRightOptions(array $value): self |
||
| 221 | { |
||
| 222 | $new = clone $this; |
||
| 223 | $new->heroFooterColumnRightOptions = $value; |
||
| 224 | return $new; |
||
| 225 | } |
||
| 226 | |||
| 227 | public function heroFooterOptions(array $value): self |
||
| 228 | { |
||
| 229 | $new = clone $this; |
||
| 230 | $new->heroFooterOptions = $value; |
||
| 231 | return $new; |
||
| 232 | } |
||
| 233 | |||
| 234 | public function language(string $value): self |
||
| 235 | { |
||
| 236 | $new = clone $this; |
||
| 237 | $new->language = $value; |
||
| 238 | return $new; |
||
| 239 | } |
||
| 240 | |||
| 241 | public function logo(string $value): self |
||
| 242 | { |
||
| 243 | $new = clone $this; |
||
| 244 | $new->logo = $value; |
||
| 245 | return $new; |
||
| 246 | } |
||
| 247 | |||
| 248 | public function navBarOptions(array $value): self |
||
| 249 | { |
||
| 250 | $new = clone $this; |
||
| 251 | $new->navBarOptions = $value; |
||
| 252 | return $new; |
||
| 253 | } |
||
| 254 | |||
| 255 | public function navBarBrandOptions(array $value): self |
||
| 256 | { |
||
| 257 | $new = clone $this; |
||
| 258 | $new->navBarBrandOptions = $value; |
||
| 259 | return $new; |
||
| 260 | } |
||
| 261 | |||
| 262 | public function navBarBrandLogoOptions(array $value): self |
||
| 263 | { |
||
| 264 | $new = clone $this; |
||
| 265 | $new->navBarBrandLogoOptions = $value; |
||
| 266 | return $new; |
||
| 267 | } |
||
| 268 | |||
| 269 | public function navBarBrandTitleOptions(array $value): self |
||
| 270 | { |
||
| 271 | $new = clone $this; |
||
| 272 | $new->navBarBrandTitleOptions = $value; |
||
| 273 | return $new; |
||
| 274 | } |
||
| 275 | |||
| 276 | public function name(string $value): self |
||
| 281 | } |
||
| 282 | } |
||
| 283 |