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

JsSandboxExecutorServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 16 1
A provides() 0 8 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\Laravel;
17
18
use Illuminate\Contracts\Container\Container;
19
use Illuminate\Support\ServiceProvider;
20
use Pinepain\JsSandbox\Executor;
21
use Pinepain\JsSandbox\Executors\ModulesNativeExecutor;
22
use Pinepain\JsSandbox\Executors\StringExecutor;
23
use V8\Context;
24
25
26
class JsSandboxExecutorServiceProvider extends ServiceProvider
27
{
28
    protected $defer = false;
29
30
    public function register()
31
    {
32
        // phpinfo();die;
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
        // dd(123);  // TODO: this causes segfault!!!, probably, it's a bug
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
        $this->app->singleton(StringExecutor::class);
35
        // TODO: if config('js_sandbox.modules_enabled') - with modules, without otherwise
36
        $this->app->singleton(ModulesNativeExecutor::class); // TODO: register native require function
37
38
        $this->app->singleton(Executor::class, function (Container $app) {
39
            $context = $app->make(Context::class);
40
            $string  = $app->make(StringExecutor::class);
41
            $module  = $app->make(ModulesNativeExecutor::class);
42
43
            return new Executor($context, $string, $module);
44
        });
45
    }
46
47
    public function provides()
48
    {
49
        return [
50
            StringExecutor::class,
51
            ModulesNativeExecutor::class,
52
            Executor::class,
53
        ];
54
    }
55
}
56