Completed
Push — master ( 45ee30...d2ebdc )
by Bogdan
11s
created

NoCallbackGuard   A

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 2
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A guard() 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\Wrappers\CallbackGuards;
17
18
19
class NoCallbackGuard implements CallbackGuardInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function guard(callable $callback): callable
25
    {
26
        //NOTE: Use at your own risk! As it does not re-throw exception back to V8, js exection continues, but as PHP
27
        //      stays in unclean state it callbacks won't be run and thus js will get undefined value instead of
28
        //      expected result, which will yield js-originated exceptions, which in turn will result in PHP exception
29
        //      which will replace original PHP exception that caused problem and set it as Exception::$previous.
30
        return $callback;
31
    }
32
}
33