Completed
Push — master ( f41754...758cec )
by Nate
02:36
created

RelayHelper::createResolver()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3.4578

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 2
cts 7
cp 0.2857
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 1
nop 0
crap 3.4578
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/relay/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/relay
7
 */
8
9
namespace Flipbox\Relay\Helpers;
10
11
use Flipbox\Skeleton\Helpers\ObjectHelper;
12
use Relay\MiddlewareInterface;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 2.0.0
17
 */
18
class RelayHelper
19
{
20
21
    /**
22
     * @return \Closure
23
     */
24
    public static function createResolver()
25
    {
26 2
        return function ($config) {
27
            if ($config instanceof MiddlewareInterface) {
28
                return $config;
29
            }
30
            return ObjectHelper::create(
31
                $config,
32
                MiddlewareInterface::class
33
            );
34 2
        };
35
    }
36
}
37