Completed
Push — wip-public-release ( 7c11a5...54ec9d )
by Bogdan
05:19
created

Executor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 43
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A executeString() 0 4 1
A execute() 0 4 1
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/php-v8-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;
17
18
19
use Pinepain\JsSandbox\Executors\ExecutorInterface;
20
use V8\Context;
21
use V8\Value;
22
23
24
class Executor
25
{
26
    /**
27
     * @var Context
28
     */
29
    private $context;
30
    /**
31
     * @var ExecutorInterface
32
     */
33
    private $string;
34
    /**
35
     * @var ExecutorInterface
36
     */
37
    private $file;
38
39
40
    public function __construct(Context $context, ExecutorInterface $string, ExecutorInterface $file)
41
    {
42
        $this->context = $context;
43
        $this->string  = $string;
44
        $this->file    = $file;
45
    }
46
47
    /**
48
     * @param string $string
49
     *
50
     * @return Value
51
     */
52
    public function executeString(string $string): Value
53
    {
54
        return $this->string->execute($this->context->getIsolate(), $this->context, $string);
55
    }
56
57
    /**
58
     * @param string $path
59
     *
60
     * @return Value
61
     */
62
    public function execute(string $path): Value
63
    {
64
        return $this->file->execute($this->context->getIsolate(), $this->context, $path);
65
    }
66
}
67