GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Row::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * ZfTable ( Module for Zend Framework 2)
4
 *
5
 * @copyright Copyright (c) 2013 Piotr Duda [email protected]
6
 * @license   MIT License
7
 */
8
9
namespace ZfTable;
10
11
use ZfTable\AbstractElement;
12
use ZfTable\Decorator\DecoratorFactory;
13
use ZfTable\Table\Exception;
14
15
class Row extends AbstractElement
16
{
17
    protected $class = array('zf-data-row');
18
19
    /**
20
     *
21
     * @var array
22
     */
23
    protected $actualRow;
24
25
26
    /**
27
     *
28
     * @param AbstractTable $table
29
     */
30
    public function __construct($table)
31
    {
32
        $this->table = $table;
33
    }
34
35
    /**
36
     *
37
     * @param string $name
38
     * @param array $options
39
     * @return Decorator\Header\AbstractHeaderDecorator
40
     */
41
    public function addDecorator($name, $options = array())
42
    {
43
        $decorator = DecoratorFactory::factoryRow($name, $options);
44
        $this->attachDecorator($decorator);
45
        $decorator->setRow($this);
46
        return $decorator;
47
    }
48
49
    /**
50
     * Get actual row
51
     *
52
     * @return array
53
     */
54
    public function getActualRow()
55
    {
56
        return $this->actualRow;
57
    }
58
59
    /**
60
     *
61
     * @param array $actualRow
62
     */
63
    public function setActualRow($actualRow)
64
    {
65
        $this->actualRow = $actualRow;
66
    }
67
68
69
    /**
70
     * Rendering all rows for table
71
     *
72
     * @param string $type html, json, array
73
     * @return string | array
74
     */
75
    public function renderRows($type = 'html')
76
    {
77
        if ($type == 'html') {
78
            return $this->renderRowHtml();
79
        } elseif ($type == 'array') {
80
            return $this->renderRowArray();
81
        } elseif ($type == 'array_assc') {
82
            return $this->renderRowArray('assc');
83
        } else {
84
            throw new Exception\InvalidArgumentException();
85
        }
86
87
    }
88
89
    /**
90
     * Rendering rows as array
91
     *
92
     * @param string $type
93
     * @return array
94
     */
95
    private function renderRowArray($type = 'normal')
96
    {
97
        $data = $this->getTable()->getData();
98
        $headers = $this->getTable()->getHeaders();
99
        $render = array();
100
101
        foreach ($data as $rowData) {
102
            $this->setActualRow($rowData);
103
            $temp = array();
104
            foreach ($headers as $name => $options) {
105
                if ($type == 'assc') {
106
                    $temp[$name] =  $this->getTable()->getHeader($name)->getCell()->render('array');
107
                } else {
108
                    $temp[] =  $this->getTable()->getHeader($name)->getCell()->render('array');
109
                }
110
            }
111
            $render[] = $temp;
112
        }
113
        return $render;
114
    }
115
116
    /**
117
     * rendering row as a html
118
     *
119
     * @return string
120
     */
121
    private function renderRowHtml()
122
    {
123
        $data = $this->getTable()->getData();
124
        $headers = $this->getTable()->getHeaders();
125
        $render = '';
126
127
        foreach ($data as $rowData) {
128
            $this->setActualRow($rowData);
129
            $rowRender = '';
130
131
            foreach ($headers as $name => $options) {
132
                $rowRender .= $this->getTable()->getHeader($name)->getCell()->render('html');
133
            }
134
135
            foreach ($this->decorators as $decorator) {
136
                $decorator->render('');
137
            }
138
139
            $render .= sprintf('<tr %s>%s</tr>', $this->getAttributes(), $rowRender);
140
            $this->clearVar();
141
        }
142
        return $render;
143
    }
144
}
145