ServiceControllerActionProxy::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 3
eloc 5
nc 2
nop 2
crap 3
1
<?php
2
namespace Fwk\Core\Action;
3
4
use Fwk\Core\Application;
5
6
class ServiceControllerActionProxy extends AbstractControllerActionProxy 
7
{
8
    protected $serviceName;
9
    
10
    protected $method;
11
12 17
    public function __construct($serviceName, $method)
13
    {
14 17
        if (empty($serviceName) || empty($method)) {
15 1
            throw new \InvalidArgumentException("Controller service name and method cannot be empty");
16
        }
17
        
18 16
        $this->serviceName  = $serviceName;
19 16
        $this->method       = $method;
20 16
    }
21
    
22
    /**
23
     * Instanciates the controller class
24
     * 
25
     * @return mixed
26
     */
27 2
    protected function instantiate(Application $app)
28
    {
29 2
        return $app->getServices()->get($this->serviceName);
30
    }
31
}
32