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 ( 951ad1...29ba67 )
by Alexey
08:55
created

FacetPropertyIterator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 21.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 2
dl 13
loc 60
ccs 21
cts 28
cp 0.75
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A current() 0 6 1
A getAttributeList() 0 18 3
A getCriteria() 13 13 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 8.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2016 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8 1
Yii::import('frontend.share.components.SqlIterator');
9
10
class FacetPropertyIterator extends SqlIterator
11
{
12
  protected $productTable = '{{product}}';
13
14
  protected $assignmentTable = '{{product_assignment}}';
15
16
  protected $propertyList;
17
18 4
  public function __construct(array $propertyList, $chunkSize, array $productIdList = null)
19
  {
20 4
    $this->propertyList = $propertyList;
21
22 4
    parent::__construct($this->getCriteria($productIdList), $this->productTable, $chunkSize);
23 4
  }
24
25 3
  public function current()
26
  {
27 3
    $row = parent::current();
28
29 3
    return $this->getAttributeList($row);
30
  }
31
32 3
  public function getAttributeList($row)
33
  {
34 3
    $getAttributeList = array();
35
36 3
    foreach($this->propertyList as $property)
37
    {
38
      if( empty($row[$property]) )
39
        continue;
40
41
      $getAttributeList[] = array(
42
        'product_id' => $row['id'],
43
        'param_id' => $property,
44
        'value' => $row[$property]
45
      );
46 3
    }
47
48 3
    return $getAttributeList;
49
  }
50
51
  /**
52
   * @param $productIdList
53
   *
54
   * @return CDbCriteria
55
   */
56 4 View Code Duplication
  protected function getCriteria($productIdList)
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...
57
  {
58 4
    $criteria = new CDbCriteria();
59 4
    $criteria->select = CMap::mergeArray(array('t.id'), $this->propertyList);
60 4
    $criteria->distinct = true;
61 4
    $criteria->join = 'JOIN '.Yii::app()->db->schema->quoteTableName($this->assignmentTable).' AS a ON a.product_id = t.id';
62 4
    $criteria->addCondition('t.parent IS NULL');
63
64 4
    if( !is_null($productIdList) )
65 4
      $criteria->addInCondition('t.id', $productIdList);
66
67 4
    return $criteria;
68
  }
69
}