Completed
Pull Request — master (#1)
by David
06:59
created

TestController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 49
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 11 3
A mutation() 0 4 1
A testLogged() 0 4 1
A testRight() 0 4 1
1
<?php
2
3
4
namespace TheCodingMachine\GraphQL\Controllers\Fixtures;
5
6
use TheCodingMachine\GraphQL\Controllers\Annotations\Logged;
7
use TheCodingMachine\GraphQL\Controllers\Annotations\Mutation;
8
use TheCodingMachine\GraphQL\Controllers\Annotations\Query;
9
use TheCodingMachine\GraphQL\Controllers\Annotations\Right;
10
11
class TestController
12
{
13
    /**
14
     * @Query
15
     * @param int $int
16
     * @param null|string $string
17
     * @param TestObject[] $list
18
     * @return TestObject
19
     */
20
    public function test(int $int, ?string $string, array $list): TestObject
21
    {
22
        $str = '';
23
        foreach ($list as $test) {
24
            if (!$test instanceof TestObject) {
25
                throw new \RuntimeException('TestObject instance expected.');
26
            }
27
            $str .= $test->getTest();
28
        }
29
        return new TestObject($string.$int.$str);
30
    }
31
32
    /**
33
     * @Mutation
34
     * @param TestObject $testObject
35
     * @return TestObject
36
     */
37
    public function mutation(TestObject $testObject): TestObject
38
    {
39
        return $testObject;
40
    }
41
42
    /**
43
     * @Query
44
     * @Logged
45
     */
46
    public function testLogged(): TestObject
47
    {
48
        return new TestObject('foo');
49
    }
50
51
    /**
52
     * @Query
53
     * @Right(name="CAN_FOO")
54
     */
55
    public function testRight(): TestObject
56
    {
57
        return new TestObject('foo');
58
    }
59
}
60