Ajde_Component_Include   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processStatic() 0 6 1
C process() 0 25 8
1
<?php
2
3
class Ajde_Component_Include extends Ajde_Component
4
{
5
    public static function processStatic(Ajde_Template_Parser $parser, $attributes)
6
    {
7
        $instance = new self($parser, $attributes);
8
9
        return $instance->process();
10
    }
11
12
    public function process()
13
    {
14
        if (!array_key_exists('route', $this->attributes)) {
15
            // TODO:
16
            throw new Ajde_Component_Exception();
17
        }
18
        $route = $this->attributes['route'];
19
        if (!$route instanceof Ajde_Core_Route) {
20
            $route = new Ajde_Core_Route($route);
21
        }
22
        $controller = Ajde_Controller::fromRoute($route);
23
        if (array_key_exists('vars',
24
                $this->attributes) && is_array($this->attributes['vars']) && !empty($this->attributes['vars'])
25
        ) {
26
            try {
27
                $view = $controller->getView();
28
                foreach ($this->attributes['vars'] as $key => $var) {
29
                    $view->assign($key, $var);
30
                }
31
            } catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
32
            }
33
        }
34
35
        return $controller->invoke();
36
    }
37
}
38