StringExecutor   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 8 1
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/js-sandbox PHP library.
5
 *
6
 * Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7
 *
8
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
9
 *
10
 * For the full copyright and license information, please view the
11
 * LICENSE file that was distributed with this source or visit
12
 * http://opensource.org/licenses/MIT
13
 */
14
15
16
namespace Pinepain\JsSandbox\Executors;
17
18
19
use V8\Context;
20
use V8\Isolate;
21
use V8\Script;
22
use V8\ScriptOrigin;
23
use V8\StringValue;
24
use V8\Value;
25
26
27
class StringExecutor implements ExecutorInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function execute(Isolate $isolate, Context $context, string $value): Value
33
    {
34
        $source = new StringValue($isolate, $value);
35
        $origin = new ScriptOrigin('<execute>');
36
        $script = new Script($context, $source, $origin);
37
38
        return $script->run($context);
39
    }
40
}
41