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

TestController::testLogged()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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