ServiceControllerActionProxy::instantiate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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