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 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.