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

DaoParametersBehavior::getVariantsByCriteria()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 3
eloc 6
nc 2
nop 3
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
Yii::import('frontend.share.behaviors.BaseDaoBehavior');
9
10
class DaoParametersBehavior extends BaseDaoBehavior
11
{
12
  protected $variants;
13
14
  protected $parameters;
15
16
  protected $parametersName;
17
18
  /**
19
   * @param string $condition
20
   * @param array $parameters
21
   * @param bool $refresh сбросить кэш
22
   * @param string|null $indexBy использовать это поле в качестве ключа в выходном массиве
23
   *
24
   * @return array
25
   */
26 View Code Duplication
  public function getVariantsByCondition($condition = '', array $parameters = array(), $refresh = false, $indexBy = 'id')
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...
27
  {
28
    $criteria = new CDbCriteria();
29
    $criteria->condition = $condition;
30
    $criteria->params = $parameters;
31
32
    return $this->getVariantsByCriteria($criteria, $refresh, $indexBy);
33
  }
34
35
  /**
36
   * @param CDbCriteria $criteria
37
   * @param bool $refresh сбросить кэш
38
   * @param string|null $indexBy использовать это поле в качестве ключа в выходном массиве
39
   *
40
   * @return array
41
   */
42 View Code Duplication
  public function getVariantsByCriteria(CDbCriteria $criteria, $refresh = false, $indexBy = null)
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...
43
  {
44
    $key = serialize($criteria);
45
46
    if( !isset($this->variants[$key]) || $refresh )
47
    {
48
      $command = $this->builder->createFindCommand(self::VARIANT_TABLE, $criteria);
49
      $this->variants[$key] = $this->indexData($command->queryAll(), $indexBy);
50
    }
51
52
    return $this->variants[$key];
53
  }
54
55
  /**
56
   * @param string $condition
57
   * @param array $parameters
58
   * @param bool $refresh сбросить кэш
59
   * @param string|null $indexBy использовать это поле в качестве ключа в выходном массиве
60
   *
61
   * @return array
62
   */
63 View Code Duplication
  public function getParametersNameByCondition($condition = '', array $parameters = array(), $refresh = false, $indexBy = 'id')
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...
64
  {
65
    $criteria = new CDbCriteria();
66
    $criteria->condition = $condition;
67
    $criteria->params = $parameters;
68
69
    return $this->getParametersNameByCriteria($criteria, $refresh, $indexBy);
70
  }
71
72
  /**
73
   * @param CDbCriteria $criteria
74
   * @param bool $refresh сбросить кэш
75
   * @param string|null $indexBy использовать это поле в качестве ключа в выходном массиве
76
   *
77
   * @return array
78
   */
79 View Code Duplication
  public function getParametersNameByCriteria(CDbCriteria $criteria, $refresh = false, $indexBy = null)
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...
80
  {
81
    $key = serialize($criteria);
82
83
    if( !isset($this->parametersName[$key]) || $refresh )
84
    {
85
      $command = $this->builder->createFindCommand(self::PARAMETER_NAME_TABLE, $criteria);
86
      $this->parametersName[$key] = $this->indexData($command->queryAll(), $indexBy);
87
    }
88
89
    return $this->parametersName[$key];
90
  }
91
92
  /**
93
   * @param CDbCriteria $criteria
94
   * @param bool $refresh сбросить кэш
95
   * @param string|null $indexBy использовать это поле в качестве ключа в выходном массиве
96
   *
97
   * @return array
98
   */
99 View Code Duplication
  public function getParametersByCriteria(CDbCriteria $criteria, $refresh = false, $indexBy = 'id')
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...
100
  {
101
    $key = serialize($criteria);
102
103
    if( !isset($this->parameters[$key]) || $refresh )
104
    {
105
      $command = $this->builder->createFindCommand(self::PARAMETER_TABLE, $criteria);
106
      $this->parameters[$key] = $this->indexData($command->queryAll(), $indexBy);
107
    }
108
109
    return $this->parameters[$key];
110
  }
111
112
  /**
113
   * @param string $condition
114
   * @param array $parameters
115
   * @param bool $refresh сбросить кэш
116
   * @param string|null $indexBy использовать это поле в качестве ключа в выходном массиве
117
   *
118
   * @return array
119
   */
120 View Code Duplication
  public function getParametersByCriteriaByCondition($condition = '', array $parameters = array(), $refresh = false, $indexBy = null)
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...
121
  {
122
    $criteria = new CDbCriteria();
123
    $criteria->condition = $condition;
124
    $criteria->params = $parameters;
125
126
    return $this->getParametersByCriteriaByCondition($criteria, $refresh, $indexBy);
127
  }
128
}