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

SaveProductsCommand::actionIndex()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 2
eloc 15
nc 2
nop 0
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 14 and the first side effect is on line 2.

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
Yii::import('backend.modules.product.models.*');
3
Yii::import('backend.models.behaviors.*');
4
Yii::import('backend.components.*');
5
Yii::import('backend.components.db.*');
6
Yii::import('backend.components.interfaces.*');
7
Yii::import('frontend.extensions.upload.components.*');
8
Yii::import('frontend.share.*');
9
Yii::import('frontend.share.behaviors.*');
10
Yii::import('frontend.share.formatters.*');
11
Yii::import('frontend.share.validators.*');
12
Yii::import('frontend.share.helpers.*');
13
14
class SaveProductsCommand extends LoggingCommand
15
{
16
  public function actionIndex()
17
  {
18
    $this->logger->log('Начало обновления подуктов');
19
20
    $criteria = new CDbCriteria();
21
    $criteria->select = 'id';
22
    //$criteria->condition = 'parent IS NULL';
23
    $command = Yii::app()->db->schema->commandBuilder->createFindCommand(BProduct::model()->tableName(), $criteria);
24
    $productIds = $command->queryColumn();
25
26
    $progress = new ConsoleProgressBar(count($productIds));
27
28
    $progress->start();
29
    foreach($productIds as $productId)
30
    {
31
      $product = BProduct::model()->findByPk($productId);
32
      $product->save();
33
      //$product->detachBehaviors();
34
      $progress->setValueMap('memory', Yii::app()->format->formatSize(memory_get_usage()));
35
      $progress->advance();
36
    }
37
    $progress->finish();
38
39
    $this->logger->log('Обновление подуктов завершено', true, true);
40
  }
41
}