ModulesNativeExecutor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 22
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 6 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 League\Flysystem\Util;
20
use Pinepain\JsSandbox\Modules\NativeRequireFunctionWrapperInterface;
21
use V8\Context;
22
use V8\Isolate;
23
use V8\Value;
24
25
26
class ModulesNativeExecutor implements ExecutorInterface
27
{
28
    /**
29
     * @var NativeRequireFunctionWrapperInterface
30
     */
31
    private $require;
32
33
    public function __construct(NativeRequireFunctionWrapperInterface $require)
34
    {
35
        $this->require = $require;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function execute(Isolate $isolate, Context $context, string $value): Value
42
    {
43
        $path = Util::normalizePath($value);
44
45
        return $this->require->call($path);
46
    }
47
}
48