Completed
Push — master ( e36103...5c707d )
by James Ekow Abaka
02:10
created

ListingHelper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
1
<?php
2
3
namespace ntentan\honam\helpers;
4
5
use ntentan\honam\TemplateEngine;
6
use ntentan\honam\Helper;
7
8
class ListingHelper extends Helper
9
{
10
    private $parameters =        array(
11
          "headers"               =>  array(),
12
          "data"                  =>  array(),
13
          "row_template"          =>  null,
14
          "cell_templates"        =>  null,
15
          "default_cell_template" =>  null,
16
          "variables"             =>  null
17
       );
18
    
19 1
    public function __construct() 
20
    {
21 1
        TemplateEngine::appendPath(
22 1
            __DIR__ . "/../../templates/lists"
23
        );
24 1
    }
25
    
26
    public function stylesheet()
27
    {
28
        return __DIR__ . '/../../assets/css/lists/lists.css';
29
    }
30
    
31
    /**
32
     *  array(
33
     *     "headers"               =>  $this->headers,
34
     *     "data"                  =>  $this->data,
35
     *     "row_template"          =>  $this->rowTemplate,
36
     *     "cell_templates"        =>  $this->cellTemplates,
37
     *     "default_cell_template" =>  $this->defaultCellTemplate,
38
     *     "variables"             =>  $this->variables,
39
     *  )
40
     * @param type $arguments
41
     */
42 1
    public function help($arguments)
43
    {
44 1
        $this->parameters = array_merge($this->parameters, $arguments);
45 1
        return $this;
46
    }
47
48 1
    public function __toString()
49
    {
50 1
        $this->parameters['row_template'] = $this->parameters['row_template'] == null ? 'row.tpl.php' : $this->parameters['row_template'];
51 1
        $this->parameters['default_cell_template'] = $this->parameters['default_cell_template'] == null ? 'default_cell.tpl.php' : $this->parameters['default_cell_template'];
52 1
        return TemplateEngine::render('list.tpl.php', $this->parameters);
53
    }
54
}
55
56