Fix up code formatting and structure for #3998
Fix up code formatting and structure for #3998

* Fix the various PHPCS errors.
* Make the logic less complex.

michaelze/cakephp,adopico/cakephp,davidyell/cakephp,ndm2/cakephp,jeffblack360/cakephp,ndm2/cakephp,berrygoudswaard/cakephp,eboominathan/cakephp,thinkingmedia/cakephp,jjj117/cakephp,dakota/cakephp,eboominathan/cakephp,eryw/cakephp,tgr0ss/cakephp,elboletaire/cakephp,ADmad/cakephp,mvdriel/cakephp,dkarvounaris/cakephp,adopico/cakephp,khoimt/cakephp-study,yinhe007/cakephp,gmponos/cakephp,jerems02/cakephp,CakeDC/cakephp,Phillaf/cakephp,gmponos/cakephp,akintoey/cakephp,khoimt/cakephp-study,tenkoma/cakephp,petteyg/cakephp,thinkingmedia/cakephp,dakota/cakephp,tisu2tisu/cakephp,bravo-kernel/cakephp,ionas/cakephp,web-player/cakephp,Phillaf/cakephp,CVO-Technologies/cakephp,khoimt/cakephp-study,bravo-kernel/cakephp,pbaire/cakephp,erikfig/cakephp,petteyg/cakephp,mvdriel/cakephp,timhoeppner/cakephp,nrother/cakephp,cakephp/cakephp,tenkoma/cakephp,ndm2/cakephp,et304383/passbolt_api,CakeDC/cakephp,Balachan27/cakephp,tisu2tisu/cakephp,adopico/cakephp,Balachan27/cakephp,et304383/passbolt_api,et304383/passbolt_api,justinyost/cakephp,tisu2tisu/cakephp,mvdriel/cakephp,jjj117/cakephp,cakephp-fr/cakephp,mvdriel/cakephp,tenkoma/cakephp,yinhe007/cakephp,elboletaire/cakephp,jeffblack360/cakephp,burriko/cakephp,cakephp/cakephp,garethellis36/cakephp,thinkingmedia/cakephp,dakota/cakephp,akintoey/cakephp,dkarvounaris/cakephp,burriko/cakephp,tenkoma/cakephp,yinhe007/cakephp,davidyell/cakephp,et304383/passbolt_api,ionas/cakephp,jeffblack360/cakephp,burriko/cakephp,cakephp/cakephp,eboominathan/cakephp,HavokInspiration/cakephp,HavokInspiration/cakephp,kumamidori/cakephp,pbaire/cakephp,kumamidori/cakephp,tgr0ss/cakephp,erikfig/cakephp,timhoeppner/cakephp,jerems02/cakephp,dakota/cakephp,berrygoudswaard/cakephp,gmponos/cakephp,CVO-Technologies/cakephp,garethellis36/cakephp,garethellis36/cakephp,ADmad/cakephp,timhoeppner/cakephp,elboletaire/cakephp,eryw/cakephp,CVO-Technologies/cakephp,Balachan27/cakephp,web-player/cakephp,garethellis36/cakephp,ADmad/cakephp,cakephp-fr/cakephp,ndm2/cakephp,jjj117/cakephp,eryw/cakephp,erikfig/cakephp,nrother/cakephp,Phillaf/cakephp,nrother/cakephp,web-player/cakephp,pbaire/cakephp,jerems02/cakephp,davidyell/cakephp,petteyg/cakephp,CakeDC/cakephp,justinyost/cakephp,ionas/cakephp,bravo-kernel/cakephp,michaelze/cakephp,michaelze/cakephp,ADmad/cakephp,akintoey/cakephp,dkarvounaris/cakephp,berrygoudswaard/cakephp,cakephp-fr/cakephp,tgr0ss/cakephp,cakephp/cakephp,petteyg/cakephp,CakeDC/cakephp,HavokInspiration/cakephp,et304383/passbolt_api,justinyost/cakephp,kumamidori/cakephp