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.

TbJsonGridColumn::renderHeaderCell()   C
last analyzed

Complexity

Conditions 11
Paths 9

Size

Total Lines 31
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 132

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 31
ccs 0
cts 30
cp 0
rs 5.2653
cc 11
eloc 22
nc 9
nop 0
crap 132

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 *## TbJsonGridColumn class file
4
 *
5
 * @author: antonio ramirez <[email protected]>
6
 * @copyright Copyright &copy; Clevertech 2012-
7
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
8
 */
9
10
Yii::import('booster.widgets.TbDataColumn');
11
12
/**
13
 *## TbJsonGridColumn class
14
 *
15
 * This column works specifically with TbJsonGridView.
16
 * This is the base class for TbJsonDataColumn
17
 *
18
 * @property TbJsonGridView $grid
19
 *
20
 * @package booster.widgets.grids.columns.json
21
 */
22
class TbJsonGridColumn extends TbDataColumn
23
{
24
25
	/**
26
	 * Renders the header cell.
27
	 */
28
	public function renderHeaderCell()
29
	{
30
		if ($this->grid->json) {
31
			$header = array('id' => $this->id);
32
			$content = array();
33
			if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
34
				$sort = $this->grid->dataProvider->getSort();
35
				$label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name);
36
37
				if ($sort->resolveAttribute($this->name) !== false) {
38
					$label .= '<span class="caret"></span>';
39
				}
40
				$content['content'] = $sort->link($this->name, $label, array('class' => 'sort-link'));
41
			} else {
42
				if ($this->name !== null && $this->header === null) {
43
					if ($this->grid->dataProvider instanceof CActiveDataProvider) {
0 ignored issues
show
Bug introduced by
The class CActiveDataProvider does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
44
						$content['content'] = CHtml::encode(
45
							$this->grid->dataProvider->model->getAttributeLabel($this->name)
46
						);
47
					} else {
48
						$content['content'] = CHtml::encode($this->name);
49
					}
50
				} else {
51
					$content['content'] = trim($this->header) !== '' ? $this->header
52
						: $this->grid->blankDisplay;
53
				}
54
			}
55
			return CMap::mergeArray($header, $content);
56
		}
57
		parent::renderHeaderCell();
58
	}
59
}
60