Troubleshooting of Sonar issue: Difference between revisions
Jump to navigation
Jump to search
no edit summary
No edit summary |
|||
| Line 19: | Line 19: | ||
} | } | ||
</pre> | </pre> | ||
== How to resolve "Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed." == | |||
Possible solution | |||
* Created smaller, more specific functions (following [https://en.wikipedia.org/wiki/Single-responsibility_principle Single Responsibility Principle]) to handle specific parts of the logic. | |||
* Use these functions to make the main function easier to read and understand. | |||
== Further reading == | == Further reading == | ||
* [https://www.php.net/manual/en/spl.exceptions.php PHP: Exceptions - Manual] | * [https://www.php.net/manual/en/spl.exceptions.php PHP: Exceptions - Manual] | ||
* [http://asika.windspeaker.co/post/3503-php-exceptions PHP Exceptions 種類與使用情境說明 | Asika Lab 飛鳥實驗室] | * [http://asika.windspeaker.co/post/3503-php-exceptions PHP Exceptions 種類與使用情境說明 | Asika Lab 飛鳥實驗室] | ||
* [https://en.wikipedia.org/wiki/Single-responsibility_principle Single-responsibility principle - Wikipedia] | |||
== References == | == References == | ||