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.

FWebUser   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 75
Duplicated Lines 42.67 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
dl 32
loc 75
ccs 30
cts 35
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 14
lcom 1
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 14 2
A getData() 0 4 1
A getProfile() 0 4 1
A getEmail() 16 16 5
A getName() 16 16 5

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 Alexey Tatarinov <[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.components.auth
8
 * @property User $data
9
 * @property UserProfile $profile
10
 * @property string $email
11
 * @property string $name
12
 */
13
class FWebUser extends CWebUser
14
{
15
  private $data = null;
16
17 1
  public function init()
18
  {
19 1
    parent::init();
20
21 1
    if( $this->isGuest )
22 1
    {
23 1
      $this->data = new User();
24 1
      $this->data->profile = new UserProfile();
25 1
    }
26
    else
27
    {
28
      $this->data = User::model()->findByPk($this->getId());
29
    }
30 1
  }
31
32
  /**
33
   * @return User|null
34
   */
35 7
  public function getData()
36
  {
37 7
    return $this->data;
38
  }
39
40
  /**
41
   * @return null|UserProfile
42
   */
43 7
  public function getProfile()
44
  {
45 7
    return $this->getData()->profile;
46
  }
47
48
  /**
49
   * @return string
50
   */
51 3 View Code Duplication
  public function getEmail()
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...
52
  {
53 3
    if( !empty($this->getData()->email) )
54 3
      return $this->getData()->email;
55
56 2
    if( isset($this->getData()->socials) )
57 2
    {
58 2
      foreach($this->getData()->socials as $social)
59
      {
60
        if( !empty($social->email) )
61
          return $social->email;
62 2
      }
63 2
    }
64
65 2
    return '';
66
  }
67
68
  /**
69
   * @return string
70
   */
71 7 View Code Duplication
  public function getName()
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...
72
  {
73 7
    if( !empty($this->getProfile()->name) )
74 7
      return $this->getProfile()->name;
75
76 4
    if( isset($this->getData()->socials) )
77 4
    {
78 4
      foreach($this->getData()->socials as $social)
79
      {
80
        if( !empty($social->name) )
81
          return $social->name;
82 4
      }
83 4
    }
84
85 4
    return '';
86
  }
87
}