Complex classes like DisplayTab 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 DisplayTab, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 18 | class DisplayTab implements TabInterface, DisplayInterface, FormInterface  | 
            ||
| 19 | { | 
            ||
| 20 | use VisibleCondition;  | 
            ||
| 21 | |||
| 22 | /**  | 
            ||
| 23 | * @var string  | 
            ||
| 24 | */  | 
            ||
| 25 | protected $label = '';  | 
            ||
| 26 | |||
| 27 | /**  | 
            ||
| 28 | * @var bool  | 
            ||
| 29 | */  | 
            ||
| 30 | protected $active = false;  | 
            ||
| 31 | |||
| 32 | /**  | 
            ||
| 33 | * @var string  | 
            ||
| 34 | */  | 
            ||
| 35 | protected $name;  | 
            ||
| 36 | |||
| 37 | /**  | 
            ||
| 38 | * @var string  | 
            ||
| 39 | */  | 
            ||
| 40 | protected $icon;  | 
            ||
| 41 | |||
| 42 | /**  | 
            ||
| 43 | * @var Renderable  | 
            ||
| 44 | */  | 
            ||
| 45 | protected $content;  | 
            ||
| 46 | |||
| 47 | /**  | 
            ||
| 48 | * @var string  | 
            ||
| 49 | */  | 
            ||
| 50 | protected $view = 'display.tab';  | 
            ||
| 51 | |||
| 52 | /**  | 
            ||
| 53 | * @param Renderable $content  | 
            ||
| 54 | * @param string|null $label  | 
            ||
| 55 | * @param string|null $icon  | 
            ||
| 56 | */  | 
            ||
| 57 | public function __construct(Renderable $content, $label = null, $icon = null)  | 
            ||
| 69 | |||
| 70 | /**  | 
            ||
| 71 | * @return string  | 
            ||
| 72 | */  | 
            ||
| 73 | public function getLabel()  | 
            ||
| 77 | |||
| 78 | /**  | 
            ||
| 79 | * @param string $label  | 
            ||
| 80 | *  | 
            ||
| 81 | * @return $this  | 
            ||
| 82 | */  | 
            ||
| 83 | public function setLabel($label)  | 
            ||
| 89 | |||
| 90 | /**  | 
            ||
| 91 | * @return bool  | 
            ||
| 92 | */  | 
            ||
| 93 | public function isActive()  | 
            ||
| 97 | |||
| 98 | /**  | 
            ||
| 99 | * @param bool $active  | 
            ||
| 100 | *  | 
            ||
| 101 | * @return $this  | 
            ||
| 102 | */  | 
            ||
| 103 | public function setActive($active = true)  | 
            ||
| 109 | |||
| 110 | /**  | 
            ||
| 111 | * @return string  | 
            ||
| 112 | */  | 
            ||
| 113 | public function getName()  | 
            ||
| 119 | |||
| 120 | /**  | 
            ||
| 121 | * @param string $name  | 
            ||
| 122 | *  | 
            ||
| 123 | * @return $this  | 
            ||
| 124 | */  | 
            ||
| 125 | public function setName($name)  | 
            ||
| 131 | |||
| 132 | /**  | 
            ||
| 133 | * @return string  | 
            ||
| 134 | */  | 
            ||
| 135 | public function getIcon()  | 
            ||
| 139 | |||
| 140 | /**  | 
            ||
| 141 | * @param string $icon  | 
            ||
| 142 | *  | 
            ||
| 143 | * @return $this  | 
            ||
| 144 | */  | 
            ||
| 145 | public function setIcon($icon)  | 
            ||
| 151 | |||
| 152 | /**  | 
            ||
| 153 | * @return Renderable  | 
            ||
| 154 | */  | 
            ||
| 155 | public function getContent()  | 
            ||
| 159 | |||
| 160 | /**  | 
            ||
| 161 | * @param string $class  | 
            ||
| 162 | *  | 
            ||
| 163 | * @return $this  | 
            ||
| 164 | */  | 
            ||
| 165 | public function setModelClass($class)  | 
            ||
| 173 | |||
| 174 | /**  | 
            ||
| 175 | * Initialize tab.  | 
            ||
| 176 | *  | 
            ||
| 177 | * @return $this  | 
            ||
| 178 | */  | 
            ||
| 179 | public function initialize()  | 
            ||
| 187 | |||
| 188 | /**  | 
            ||
| 189 | * @param string $action  | 
            ||
| 190 | *  | 
            ||
| 191 | * @return $this  | 
            ||
| 192 | */  | 
            ||
| 193 | public function setAction($action)  | 
            ||
| 201 | |||
| 202 | /**  | 
            ||
| 203 | * @param int $id  | 
            ||
| 204 | *  | 
            ||
| 205 | * @return $this  | 
            ||
| 206 | */  | 
            ||
| 207 | public function setId($id)  | 
            ||
| 215 | |||
| 216 | /**  | 
            ||
| 217 | * @param ModelConfigurationInterface $model  | 
            ||
| 218 | *  | 
            ||
| 219 | * @return Validator|null  | 
            ||
| 220 | */  | 
            ||
| 221 | public function validateForm(ModelConfigurationInterface $model)  | 
            ||
| 227 | |||
| 228 | /**  | 
            ||
| 229 | * Save model.  | 
            ||
| 230 | *  | 
            ||
| 231 | * @param ModelConfigurationInterface $model  | 
            ||
| 232 | *  | 
            ||
| 233 | * @return $this  | 
            ||
| 234 | */  | 
            ||
| 235 | public function saveForm(ModelConfigurationInterface $model)  | 
            ||
| 243 | |||
| 244 | /**  | 
            ||
| 245 | * @return string  | 
            ||
| 246 | */  | 
            ||
| 247 | public function getView()  | 
            ||
| 251 | |||
| 252 | /**  | 
            ||
| 253 | * Set currently rendered instance.  | 
            ||
| 254 | *  | 
            ||
| 255 | * @param Model $model  | 
            ||
| 256 | */  | 
            ||
| 257 | public function setModel(Model $model)  | 
            ||
| 263 | |||
| 264 | /**  | 
            ||
| 265 | * @return Model $model  | 
            ||
| 266 | */  | 
            ||
| 267 | public function getModel()  | 
            ||
| 273 | |||
| 274 | /**  | 
            ||
| 275 | * Get form item validation rules.  | 
            ||
| 276 | * @return array  | 
            ||
| 277 | */  | 
            ||
| 278 | public function getValidationRules()  | 
            ||
| 286 | |||
| 287 | /**  | 
            ||
| 288 | * @return array  | 
            ||
| 289 | */  | 
            ||
| 290 | public function getValidationMessages()  | 
            ||
| 298 | |||
| 299 | /**  | 
            ||
| 300 | * @return array  | 
            ||
| 301 | */  | 
            ||
| 302 | public function getValidationLabels()  | 
            ||
| 310 | |||
| 311 | /**  | 
            ||
| 312 | * Save form item.  | 
            ||
| 313 | */  | 
            ||
| 314 | public function save()  | 
            ||
| 320 | |||
| 321 | /**  | 
            ||
| 322 | * Save form item.  | 
            ||
| 323 | */  | 
            ||
| 324 | public function afterSave()  | 
            ||
| 330 | |||
| 331 | /**  | 
            ||
| 332 | * @param string $path  | 
            ||
| 333 | *  | 
            ||
| 334 | * @return FormElementInterface|null  | 
            ||
| 335 | */  | 
            ||
| 336 | public function getElement($path)  | 
            ||
| 342 | |||
| 343 | /**  | 
            ||
| 344 | * @return Collection  | 
            ||
| 345 | */  | 
            ||
| 346 | public function getElements()  | 
            ||
| 352 | |||
| 353 | /**  | 
            ||
| 354 | * @param array $elements  | 
            ||
| 355 | *  | 
            ||
| 356 | * @return $this  | 
            ||
| 357 | */  | 
            ||
| 358 | public function setElements(array $elements)  | 
            ||
| 364 | |||
| 365 | /**  | 
            ||
| 366 | * @return mixed  | 
            ||
| 367 | */  | 
            ||
| 368 | public function getValue()  | 
            ||
| 374 | |||
| 375 | /**  | 
            ||
| 376 | * @return bool  | 
            ||
| 377 | */  | 
            ||
| 378 | public function isReadonly()  | 
            ||
| 386 | |||
| 387 | /**  | 
            ||
| 388 | * @return array  | 
            ||
| 389 | */  | 
            ||
| 390 | public function toArray()  | 
            ||
| 399 | |||
| 400 | /**  | 
            ||
| 401 | * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory  | 
            ||
| 402 | */  | 
            ||
| 403 | public function render()  | 
            ||
| 407 | |||
| 408 | /**  | 
            ||
| 409 | * @return string  | 
            ||
| 410 | */  | 
            ||
| 411 | public function __toString()  | 
            ||
| 415 | }  | 
            ||
| 416 | 
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.