ServiceExampleController::indexAction()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace Saxulum\SaxulumControllerProvider\Controller;
4
5
use Silex\Application;
6
7
class ServiceExampleController implements ControllerRouteInterface
8
{
9
    /**
10
     * @var array
11
     */
12
    protected $testData;
13
14
    /**
15
     * @var array
16
     */
17
    protected $testData1;
18
19
    /**
20
     * @var array
21
     */
22
    protected $testData2;
23
24
    /**
25
     * @param Application $app
26
     * @param string      $serviceId
27
     */
28
    public static function addRoutes(Application $app, $serviceId)
29
    {
30
        $app
31
            ->get('/service', $serviceId . ':indexAction')
32
            ->bind('service_index')
33
        ;
34
    }
35
36
    /**
37
     * @param array $testData
38
     */
39
    public function __construct(array $testData)
40
    {
41
        $this->testData = $testData;
42
    }
43
44
    /**
45
     * @param array $testData1
46
     */
47
    public function setTestData1(array $testData1)
48
    {
49
        $this->testData1 = $testData1;
50
    }
51
52
    /**
53
     * @param array $testData2
54
     */
55
    public function setTestData2(array $testData2)
56
    {
57
        $this->testData2 = $testData2;
58
    }
59
60
    public function indexAction()
61
    {
62
        if(array_key_exists('key1', $this->testData) &&
63
           array_key_exists('key1', $this->testData1) &&
64
           array_key_exists('key1', $this->testData2)) {
65
            return 'ok';
66
        }
67
68
        return 'failed';
69
    }
70
}
71