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

TestController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 11 3
A mutation() 0 4 1
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