deComplex.me Logo diff and reduce the complexity of your PHP code
Reset Editors

Editor #1

Press the button to calculate complexities!
Looks like your code has a syntax error!
X
Cyclomatic
Complexity
Loading response ...
X
Cognitive
Complexity

Editor #2

Press the button to calculate complexities!
Looks like your code has a syntax error!
X
Cyclomatic
Complexity
Loading response ...
X
Cognitive
Complexity
Please be aware that your code snippets get stored on server-side while using this feature, but it's not used for some crazy AI stuff or anything else than the permalink.

Complexity Levels

Low
0 ‐ 4
Moderate
4 ‐ 7
High
7 ‐ 10
Very High
> 10

Cyclomatic Complexity

Cyclomatic complexity is computed using the control flow graph of the program: the nodes of the graph correspond to indivisible groups of commands of a program, and a directed edge connects two nodes if the second command might be executed immediately after the first command. Cyclomatic complexity may also be applied to individual functions, modules, methods or classes within a program. See Wikipedia for more information.

To measure or enforce cyclomatic complexity limits in your application see PHPLOC or PHP Mess Detector.

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity it was formulated with the primary goal of calculating method scores that more accurately reflect methods’ relative understandability, and with secondary goals of addressing modern language constructs and producing metrics that are valuable above the method level. See SonarSource's Whitepaper for more information.

To enforce cognitive complexity limits in your application with PHPStan see Tomas Votruba's blog post.