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.

SwitchAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 4
1
<?php
2
3
/**
4
 * CToggleColumn class file.
5
 * @author Nikola Trifunovic <[email protected]>
6
 * @link http://www.trifunovic.me/
7
 * @copyright Copyright &copy; 2012 Nikola Trifunovic
8
 * @license http://www.yiiframework.com/license/
9
 */
10
class SwitchAction extends CAction
11
{
12
  public function run($id, $attribute)
13
  {
14
    if( Yii::app()->request->isPostRequest )
15
    {
16
      // we only allow deletion via POST request
17
      $model = $this->controller->loadModel($id);
18
      $model->updateAll(array($attribute => 0));
19
      $model->$attribute = 1;
20
      $model->save(false);
21
22
      // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
23
      if( !isset($_GET['ajax']) )
24
        $this->controller->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
25
    }
26
    else
27
      throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
28
  }
29
}
30
31
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
32