Passed
Push — master ( ba1e45...7b307a )
by David
03:05
created

TestController::test()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 3
nop 3
1
<?php
2
3
4
namespace TheCodingMachine\GraphQL\Controllers\Fixtures;
5
6
7
use TheCodingMachine\GraphQL\Controllers\Annotations\Mutation;
8
use TheCodingMachine\GraphQL\Controllers\Annotations\Query;
9
10
class TestController
11
{
12
    /**
13
     * @Query()
14
     * @param int $int
15
     * @param null|string $string
16
     * @param TestObject[] $list
17
     * @return TestObject
18
     */
19
    public function test(int $int, ?string $string, array $list): TestObject
20
    {
21
        $str = '';
22
        foreach ($list as $test) {
23
            if (!$test instanceof TestObject) {
24
                throw new \RuntimeException('TestObject instance expected.');
25
            }
26
            $str .= $test->getTest();
27
        }
28
        return new TestObject($string.$int.$str);
29
    }
30
31
    /**
32
     * @Mutation()
33
     * @param TestObject $testObject
34
     * @return TestObject
35
     */
36
    public function mutation(TestObject $testObject): TestObject
37
    {
38
        return $testObject;
39
    }
40
}
41