Desmond   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 36
ccs 17
cts 17
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A run() 0 13 3
A loadFile() 0 4 1
A pretty() 0 4 2
1
<?php
2
3
namespace Desmond;
4
5
class Desmond
6
{
7
    const VERSION = '0.3.6';
8
    private $lexer;
9
    private $eval;
10
11 6
    public function __construct()
12
    {
13 6
        $this->lexer = new Lexer();
14 6
        $this->eval = new Evaluator();
15 6
    }
16
17 6
    public function run($command)
18
    {
19 6
        if (empty($command)) {
20 1
            return '';
21
        }
22
        try {
23 5
            $ast = $this->lexer->readString($command);
24 4
            $value = $this->eval->getReturn($ast);
25 1
        } catch (\Exception $exception) {
26 1
            return $exception->getMessage();
27
        }
28 4
        return $value;
29
    }
30
31 1
    public function loadFile($file)
32
    {
33 1
        $this->run('(load-file "' . $file . '")');
34 1
    }
35
36 2
    public function pretty($value)
37
    {
38 2
        return method_exists('__toString', $value) ? $value->__toString() : $value;
39
    }
40
}
41