Program::evaluate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PeacefulBit\Slate\Parser\Nodes;
4
5
use PeacefulBit\Slate\Core\Evaluator;
6
use PeacefulBit\Slate\Core\Frame;
7
8 View Code Duplication
class Program extends Node
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    private $body;
11
12
    /**
13
     * @param $body
14
     */
15
    public function __construct($body)
16
    {
17
        $this->body = $body;
18
    }
19
20
    /**
21
     * @return mixed
22
     */
23
    public function getBody()
24
    {
25
        return $this->body;
26
    }
27
28
    /**
29
     * @return string
30
     */
31
    public function __toString()
32
    {
33
        return implode(PHP_EOL, array_map('strval', $this->getBody()));
34
    }
35
36
    /**
37
     * @param Frame $frame
38
     * @return mixed
39
     */
40
    public function evaluate(Frame $frame)
41
    {
42
        return array_reduce($this->getBody(), function ($result, $expression) use ($frame) {
43
            return $frame->evaluate($expression);
44
        }, null);
45
    }
46
}
47