Passed
Push — master ( e7bef7...3228c5 )
by Vladimir
03:06
created

Addition::resolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
interface Resolver {
4
    public function resolve($rootValue, $args, $context);
5
}
6
7
class Addition implements Resolver
8
{
9
    public function resolve($rootValue, $args, $context)
10
    {
11
        return $args['x'] + $args['y'];
12
    }
13
}
14
15
class Echoer implements Resolver
16
{
17
    public function resolve($rootValue, $args, $context)
18
    {
19
        return $rootValue['prefix'].$args['message'];
20
    }
21
}
22
23
return [
24
    'sum' => function($rootValue, $args, $context) {
25
        $sum = new Addition();
26
27
        return $sum->resolve($rootValue, $args, $context);
28
    },
29
    'echo' => function($rootValue, $args, $context) {
30
        $echo = new Echoer();
31
32
        return $echo->resolve($rootValue, $args, $context);
33
    },
34
    'prefix' => 'You said: ',
35
];
36