Script   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 28
ccs 5
cts 7
cp 0.7143
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A evaluate() 0 3 1
1
<?php
2
3
namespace Pilipinews\Website\Sunstar;
4
5
use Nacmartin\PhpExecJs\PhpExecJs as Executor;
6
use Nacmartin\PhpExecJs\Runtime\ExternalRuntime;
7
8
/**
9
 * Sunstar Script Evaluator
10
 *
11
 * @package Pilipinews
12
 * @author  Rougin Gutib <[email protected]>
13
 */
14
class Script
15
{
16
    /**
17
     * @var \Nacmartin\PhpExecJs\PhpExecJs
18
     */
19
    protected $executor;
20
21
    /**
22
     * Initializes the evaluator instance.
23
     */
24 33
    public function __construct()
25
    {
26 33
        $binaries = array('node', 'nodejs');
27
28 33
        $runtime = new ExternalRuntime(null, $binaries);
29
30 33
        $this->executor = new Executor($runtime);
31 33
    }
32
33
    /**
34
     * Evaluates the given Javascript code.
35
     *
36
     * @param  string $script
37
     * @return string
38
     */
39
    public function evaluate($script)
40
    {
41
        return $this->executor->evalJs($script);
42
    }
43
}
44