Passed
Push — master ( af6eb6...d676d9 )
by Rougin
02:15
created

Script   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
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 33
    public function evaluate($script)
40
    {
41 33
        return $this->executor->evalJs($script);
42
    }
43
}
44