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.
Completed
Push — master ( 1ba1f4...ea41a5 )
by Alexey
05:37
created

BTagController::actionAppendTag()   C

Complexity

Conditions 7
Paths 22

Size

Total Lines 35
Code Lines 19

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 35
rs 6.7272
cc 7
eloc 19
nc 22
nop 0
1
<?php
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2015 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
class BTagController extends BController
9
{
10
  public $position = 10;
11
12
  public $name = 'Теги';
13
14
  public $modelClass = 'BTag';
15
16
  public function actionAppendTag()
17
  {
18
    try
19
    {
20
      if( $data = Yii::app()->request->getPost('appendTag') )
21
      {
22
        $tagName = Yii::app()->format->trim($data['name']);
23
24
        if( !$tag = BTag::model()->findByAttributes(array('name' => $tagName, 'group' => $data['group'])) )
25
        {
26
          $tag = new BTag();
27
          $tag->setAttributes($data);
28
          if( !$tag->save() )
29
            throw new ModelValidateException($tag);
30
        }
31
32
        if( !TagItem::model()->findByAttributes(array('tag_id' => $tag->id, 'group' => $tag->group, 'item_id' => $data['itemId'])) )
33
        {
34
          $tagItem = new TagItem();
35
          $tagItem->setAttributes(array(
36
            'tag_id' => $tag->id,
37
            'group' => $tag->group,
38
            'item_id' => $data['itemId']
39
          ));
40
41
          if( !$tagItem->save() )
42
            throw new ModelValidateException($tagItem);
43
        }
44
      }
45
    }
46
    catch(ModelValidateException $e)
47
    {
48
      throw new Http404Exception(500, $e->getMessage());
49
    }
50
  }
51
52
  public function actionDeleteTagItem()
53
  {
54
    if( $data = Yii::app()->request->getPost('deleteTag') )
55
    {
56
      if( $model = TagItem::model()->findByAttributes(array('tag_id' => $data['id'], 'group' => $data['group'], 'item_id' => $data['itemId'])) )
57
      {
58
        if( !$model->delete() )
59
          throw new WarningException('Не удалсь удалить tag');
60
      }
61
    }
62
  }
63
}