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

FacetParameterIterator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 55%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 49
ccs 11
cts 20
cp 0.55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A current() 0 6 1
A getAttributeList() 0 11 3
A getCriteria() 0 12 2
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 FacetParameterIterator extends SqlIterator
11
{
12
  protected $parameterTable = '{{product_param}}';
13
14
  protected $parameterVariantTable = '{{product_param_variant}}';
15
16 4
  public function __construct(array $parameterList, $chunkSize, array $productIdList = null)
17
  {
18 4
    parent::__construct($this->getCriteria($parameterList, $productIdList), $this->parameterTable, $chunkSize);
19 4
  }
20
21
  public function current()
22
  {
23
    $row = parent::current();
24
25
    return $this->getAttributeList($row);
26
  }
27
28
  public function getAttributeList($row)
29
  {
30
    if( !($value = !empty($row['variant_id']) ? $row['variant_id'] : $row['value']) )
31
      return null;
32
33
    return array(array(
34
      'product_id' => $row['product_id'],
35
      'param_id' => $row['param_id'],
36
      'value' => $value
37
    ));
38
  }
39
40
  /**
41
   * @param $parameterList
42
   * @param $productIdList
43
   *
44
   * @return CDbCriteria
45
   */
46 4
  protected function getCriteria($parameterList, $productIdList)
47
  {
48 4
    $criteria = new CDbCriteria();
49 4
    $criteria->select = 't.id, t.param_id, t.product_id, t.variant_id, t.value, v.name';
50 4
    $criteria->join = 'LEFT OUTER JOIN '.Yii::app()->db->schema->quoteTableName($this->parameterVariantTable).' AS v ON v.id = t.variant_id';
51 4
    $criteria->addInCondition('t.param_id', $parameterList);
52
53 4
    if( !is_null($productIdList) )
54 4
      $criteria->addInCondition('t.product_id', $productIdList);
55
56 4
    return $criteria;
57
  }
58
}