Executor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
crap 2
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;
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
     * @param Context           $context
41
     * @param ExecutorInterface $string
42
     * @param ExecutorInterface $file
43
     *
44
     */
45
    public function __construct(Context $context, ExecutorInterface $string, ExecutorInterface $file)
46
    {
47
        $this->context = $context;
48
        $this->string  = $string;
49
        $this->file    = $file;
50
    }
51
52
    /**
53
     * @param string $string
54
     *
55
     * @return Value
56
     */
57
    public function executeString(string $string): Value
58
    {
59
        return $this->string->execute($this->context->getIsolate(), $this->context, $string);
60
    }
61
62
    /**
63
     * @param string $path
64
     *
65
     * @return Value
66
     */
67
    public function execute(string $path): Value
68
    {
69
        return $this->file->execute($this->context->getIsolate(), $this->context, $path);
70
    }
71
}
72