Passed
Pull Request — master (#318)
by Sam
03:54
created

CallableMiddleware   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handleExecutionError() 0 3 1
1
<?php
2
3
namespace Digia\GraphQL\Error\Handler;
4
5
use Digia\GraphQL\Execution\ExecutionContext;
6
use Digia\GraphQL\Execution\ExecutionException;
7
8
class CallableMiddleware extends AbstractErrorMiddleware
9
{
10
    /**
11
     * @var callable
12
     */
13
    protected $handleCallback;
14
15
    /**
16
     * CallableMiddleware constructor.
17
     * @param callable $handleCallback
18
     */
19
    public function __construct(callable $handleCallback)
20
    {
21
        $this->handleCallback = $handleCallback;
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function handleExecutionError(ExecutionException $exception, ExecutionContext $context, callable $next)
28
    {
29
        return \call_user_func($this->handleCallback, $exception, $context, $next);
30
    }
31
}
32