NPath complexity and cyclomatic complexity explained

Both terms are used to determine the complexity of code. It's always good to keep your code simple and readable as referred in KISS principle.

CyclomaticComplexity
https://phpmd.org/rules/codesize.html

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

NPath complexity

The NPath complexity of a method is the number of acyclic execution paths through that method.

References:

ttps://www.tutorialspoint.com/softwaretestingdictionary/cyclomatic_complexity.htm

https://modess.io/npath-complexity-cyclomatic-complexity-explained/

Markup accessing page parameters as object or array for OctoberCMS

You can access the current URL parameters via this.param and it returns a PHP array.

Accessing page parameters

This example demonstrates how to access the tab URL parameter in a page.

url = "/account/:tab"
==
{% if this.param.tab == 'details' %}

    

Here are all your details

{% elseif this.param.tab == 'history' %}

You are viewing a blast from the past

{% endif %}

If the parameter name is also a variable, then array syntax can be used.

url = "/account/:post_id"
==
{% set name = 'post_id' %}

The post ID is: {{ this.param[name] }}

reference: https://octobercms.com/docs/markup/this-param