Completed
Push — master ( db23dc...cb2e11 )
by Dmitry
14:06
created

EndpointProviderTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A call() 0 6 1
A collectionOf() 0 4 1
A checkSelf() 0 6 1
A input() 0 5 1
A output() 0 5 1
1
<?php
2
3
namespace hiapi\endpoints;
4
5
use Closure;
6
use Guzzle\Common\Collection;
7
8
trait EndpointProviderTrait
9
{
10
    protected function call(string $className): \Closure
11
    {
12
        return static function ($input, callable $next) use ($className) {
0 ignored issues
show
Unused Code introduced by
The parameter $next is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
            return \Yii::$container->get($className)->__invoke($input);
14
        };
15
    }
16
17
    protected function collectionOf(string $className): \Closure
18
    {
19
        return Collection::of($className);
20
    }
21
22
    // TODO: move to internal project
23
    protected function checkSelf(): Closure
24
    {
25
        return static function ($command, $next) {
26
            return $next($command);
27
        };
28
    }
29
30
    protected function input(array $inputOptions): array
31
    {
32
        // TODO: Take Tafid's Pact PR
33
        return $inputOptions;
34
    }
35
    protected function output(array $inputOptions): array
36
    {
37
        // TODO: Take Tafid's Pact PR
38
        return $inputOptions;
39
    }
40
}
41