FunctionList   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 20.83 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 5
loc 24
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A id() 0 4 1
A run() 5 14 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Desmond\functions\core;
3
use Desmond\functions\DesmondFunction;
4
use Desmond\functions\FileOperations;
5
6
class FunctionList extends DesmondFunction
7
{
8
    use \Desmond\TypeHelper;
9
10 334
    public function id()
11
    {
12 334
        return 'function-list';
13
    }
14
15 1
    public function run(array $args)
16
    {
17
        $list = [
18 1
            'define', 'let', 'do', 'if',
19
            'lambda', 'load-file', 'eval',
20
            'try'
21
        ];
22 1 View Code Duplication
        foreach (FileOperations::getFunctionFiles() as $file) {
23 1
            $class = sprintf('Desmond\\functions\\core\\%s', substr($file, 0, -4));
24 1
            $function = new $class;
25 1
            $list[] = $function->id();
26
        }
27 1
        return self::fromPhpType($list);
28
    }
29
}
30