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.

LocationBase::unique()   B
last analyzed

Complexity

Conditions 11
Paths 17

Size

Total Lines 28

Duplication

Lines 4
Ratio 14.29 %

Importance

Changes 0
Metric Value
cc 11
nc 17
nop 2
dl 4
loc 28
rs 7.3166
c 0
b 0
f 0

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
 * @author Vladimir Utenkov <[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.sitemap
8
 */
9
abstract class LocationBase extends CComponent implements ILocationGenerator
10
{
11
  /**
12
   * @var CDataProviderIterator
13
   */
14
  protected $_modelSource;
15
  /**
16
   * @var CController
17
   */
18
  protected $_controller;
19
20
  /**
21
   * @param CController $controller
22
   */
23
  public function __construct(CController $controller)
24
  {
25
    $this->_controller = $controller;
26
  }
27
28
  /**
29
   * @return string
30
   */
31
  public abstract function getRoute();
32
33
  /**
34
   * @return string
35
   */
36
  public abstract function current();
37
38
  public function next()
39
  {
40
    $this->_modelSource->next();
41
  }
42
43
  /**
44
   * @return int
45
   */
46
  public function key()
47
  {
48
    return $this->_modelSource->key();
49
  }
50
51
  /**
52
   * @return bool
53
   */
54
  public function valid()
55
  {
56
    return $this->_modelSource->valid();
57
  }
58
59
  public function rewind()
60
  {
61
    $this->_modelSource->rewind();
62
  }
63
64
  public function unique(array $keys, array $dataSource)
65
  {
66
    foreach($dataSource as $key => $data)
67
    {
68
      foreach($dataSource as $key_ => $value_)
69
      {
70
        if( $key != $key_ )
71
        {
72
          $delete = true;
73
74
          foreach($keys as $value)
75
          {
76
            if( isset($dataSource[$key][$value]) && isset($dataSource[$key_][$value]) )
77 View Code Duplication
              if( $dataSource[$key][$value] != $dataSource[$key_][$value] )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
78
                $delete = false;
79
80 View Code Duplication
            if( !isset($dataSource[$key][$value]) && isset($dataSource[$key_][$value]) )
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
81
              $delete = false;
82
          }
83
84
          if( $delete )
85
            unset($dataSource[$key_]);
86
        }
87
      }
88
    }
89
90
    return $dataSource;
91
  }
92
}