Completed
Pull Request — master (#4)
by James Ekow Abaka
03:06 queued 36s
created

ListingHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 45
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A help() 0 4 1
A stylesheet() 0 3 1
A __toString() 0 5 3
1
<?php
2
3
4
namespace ntentan\honam\engines\php\helpers;
5
6
use ntentan\honam\engines\php\Helper;
7
8
9
class ListingHelper extends Helper
10
{
11
    private $parameters =        array(
12
          "headers"               =>  array(),
13
          "data"                  =>  array(),
14
          "row_template"          =>  null,
15
          "cell_templates"        =>  null,
16
          "default_cell_template" =>  null,
17
          "variables"             =>  null
18
       );
19
    
20
    public function stylesheet()
21
    {
22
        return __DIR__ . '/../../assets/css/lists/lists.css';
23
    }
24
25
    /**
26
     *  array(
27
     *     "headers"               =>  $this->headers,
28
     *     "data"                  =>  $this->data,
29
     *     "row_template"          =>  $this->rowTemplate,
30
     *     "cell_templates"        =>  $this->cellTemplates,
31
     *     "default_cell_template" =>  $this->defaultCellTemplate,
32
     *     "variables"             =>  $this->variables,
33
     *  )
34
     * @param array $arguments
35
     * @return ListingHelper
36
     */
37 1
    public function help($arguments)
38
    {
39 1
        $this->parameters = array_merge($this->parameters, $arguments);
40 1
        return $this;
41
    }
42
43
    /**
44
     * @return string
45
     * @throws \ntentan\honam\exceptions\FactoryException
46
     * @throws \ntentan\honam\exceptions\TemplateEngineNotFoundException
47
     * @throws \ntentan\honam\exceptions\TemplateResolutionException
48
     */
49 1
    public function __toString()
50
    {
51 1
        $this->parameters['row_template'] = $this->parameters['row_template'] == null ? 'row.tpl.php' : $this->parameters['row_template'];
52 1
        $this->parameters['default_cell_template'] = $this->parameters['default_cell_template'] == null ? 'default_cell.tpl.php' : $this->parameters['default_cell_template'];
53 1
        return $this->templateRenderer->render('list.tpl.php', $this->parameters);
54
    }
55
}
56
57