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.

FActiveDataProvider   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 45
Duplicated Lines 24.44 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 11
loc 45
rs 10
c 0
b 0
f 0
ccs 20
cts 24
cp 0.8333
wmc 9
lcom 0
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 4
A fetchData() 0 7 1
A afterFetchData() 0 5 2
A onAfterFetchData() 0 4 1
A getDataRandom() 0 7 1

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 Sergey Glagolev <[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
8
 */
9
class FActiveDataProvider extends CActiveDataProvider
10
{
11
  /**
12
   * @param mixed $modelClass
13
   * @param array $config
14
   */
15 2 View Code Duplication
  public function __construct($modelClass, $config = array())
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...
16
  {
17 2
    if( !isset($config['pagination']) )
18 2
      $config['pagination'] = new FPagination();
19
20 2
    $controller = Yii::app()->controller;
21 2
    if( isset($controller->pageSize) && $config['pagination'] )
22 2
      $config['pagination']->pageSize = $controller->pageSize;
23
24 2
    parent::__construct($modelClass, $config);
25 2
  }
26
27 2
  public function fetchData()
28
  {
29 2
    $data = parent::fetchData();
30 2
    $this->setData($data);
31 2
    $this->afterFetchData();
32 2
    return $data;
33
  }
34
35 2
  public function afterFetchData()
36
  {
37 2
    if( $this->hasEventHandler('onAfterFetchData') )
38 2
      $this->onAfterFetchData(new CEvent($this));
39 2
  }
40
41 2
  public function onAfterFetchData($event)
42
  {
43 2
    $this->raiseEvent('onAfterFetchData', $event);
44 2
  }
45
46
  public function getDataRandom($refresh = false)
47
  {
48
    $data = parent::getData($refresh);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getData() instead of getDataRandom()). Are you sure this is correct? If so, you might want to change this to $this->getData().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
49
    shuffle($data);
50
51
    return $data;
52
  }
53
}