phplib/Configuration.php
Function get_configuration
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
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)) {
- Read upRead up
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
Open
class Configuration {
- Exclude checks
Method name "Configuration::feature_enabled" is not in camel caps format Open
Open
static function feature_enabled($name = null) {
- Exclude checks
Visibility must be declared on method "get_navbar_features" Open
Open
static function get_navbar_features() {
- Exclude checks
Method name "Configuration::get_configuration" is not in camel caps format Open
Open
static function get_configuration($name = null) {
- Exclude checks
Visibility must be declared on method "feature_enabled" Open
Open
static function feature_enabled($name = null) {
- Exclude checks
Blank line found at start of control structure Open
Open
foreach ($c['feature'] as $feature) {
- Exclude checks
Visibility must be declared on method "get_configuration" Open
Open
static function get_configuration($name = null) {
- Exclude checks
Method name "Configuration::get_navbar_features" is not in camel caps format Open
Open
static function get_navbar_features() {
- Exclude checks
Opening brace of a class must be on the line after the definition Open
Open
class Configuration {
- Exclude checks
Expected 1 space after FOREACH keyword; 0 found Open
Open
foreach($config["feature"] as $feature) {
- Exclude checks
Opening brace should be on a new line Open
Open
static function get_configuration($name = null) {
- Exclude checks
Opening brace should be on a new line Open
Open
static function get_navbar_features() {
- Exclude checks
Opening brace should be on a new line Open
Open
static function feature_enabled($name = null) {
- Exclude checks