phplib/Configuration.php

Summary

Maintainability
A
35 mins
Test Coverage

Function get_configuration has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    static function get_configuration($name = null) {
        $enviroment = getenv('MORGUE_ENVIRONMENT') ?: 'development';
        $configfile = dirname(__FILE__).'/../config/'.$enviroment.'.json';
        $config = json_decode(file_get_contents($configfile), true);
        if (is_null($name)) {
Severity: Minor
Found in phplib/Configuration.php - About 35 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Configuration {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Method name "Configuration::feature_enabled" is not in camel caps format
Open

    static function feature_enabled($name = null) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Visibility must be declared on method "get_navbar_features"
Open

    static function get_navbar_features() {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Method name "Configuration::get_configuration" is not in camel caps format
Open

    static function get_configuration($name = null) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Visibility must be declared on method "feature_enabled"
Open

    static function feature_enabled($name = null) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Blank line found at start of control structure
Open

        foreach ($c['feature'] as $feature) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Visibility must be declared on method "get_configuration"
Open

    static function get_configuration($name = null) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Method name "Configuration::get_navbar_features" is not in camel caps format
Open

    static function get_navbar_features() {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Opening brace of a class must be on the line after the definition
Open

class Configuration {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Expected 1 space after FOREACH keyword; 0 found
Open

            foreach($config["feature"] as $feature) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function get_configuration($name = null) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function get_navbar_features() {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

Opening brace should be on a new line
Open

    static function feature_enabled($name = null) {
Severity: Minor
Found in phplib/Configuration.php by phpcodesniffer

There are no issues that match your filters.

Category
Status