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.

ContactGroup   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 16.67 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 7
loc 42
rs 10
c 0
b 0
f 0
ccs 8
cts 12
cp 0.6667
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 4 1
A defaultScope() 0 8 1
A relations() 0 6 1
A getByKey() 7 7 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * @author Nikita Melnikov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2014 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 * @package frontend.models.contact
8
 *
9
 * @property integer $id
10
 * @property integer $contact_id
11
 * @property string $name
12
 * @property integer $position
13
 * @property integer $visible
14
 * @property string $sysname
15
 *
16
 * The followings are the available model relations:
17
 * @property Contact $contact
18
 * @property ContactField[] $contactFields
19
 */
20
class ContactGroup extends FActiveRecord
21
{
22
  protected static $groups = array();
23
24 3
  public function tableName()
25
  {
26 3
    return '{{contact_group}}';
27
  }
28
29 13
  public function defaultScope()
30
  {
31 13
    $alias = $this->getTableAlias(false, false);
32
33
    return array(
34
      'condition' => $alias.'.visible = 1'
35 13
    );
36
  }
37
38 1
  public function relations()
39
  {
40
    return array(
41 1
      'fields' => array(self::HAS_MANY, 'ContactField', 'group_id', 'order' => 'f.position ASC', 'alias' => 'f'),
42 1
    );
43
  }
44
45
  /**
46
   * Получение группы полей по системному имени (поле sysname)
47
   *
48
   * @static
49
   *
50
   * @param string $key
51
   *
52
   * @return ContactGroup
53
   */
54 View Code Duplication
  public static function getByKey($key)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
  {
56
    if( empty(self::$groups[$key]) )
57
      self::$groups[$key] = self::model()->findByAttributes(array('sysname' => $key));
58
59
    return self::$groups[$key];
60
  }
61
}