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

AbstractImportCommand   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 49
Duplicated Lines 28.57 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 2
dl 14
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A behaviors() 0 9 1
A beginTransaction() 14 14 4
A commitTransaction() 0 8 2
A rollbackTransaction() 0 8 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
2
/**
3
 * @author Alexey Tatarinov <[email protected]>
4
 * @link https://github.com/shogodev/argilla/
5
 * @copyright Copyright &copy; 2003-2015 Shogo
6
 * @license http://argilla.ru/LICENSE
7
 */
8
9
/**
10
 * Class AbstractImportCommand
11
 * @mixin CurrentTransactionBehavior
12
 */
13
class AbstractImportCommand extends LoggingCommand
14
{
15
  public $logFileName = 'import.log';
16
17
  protected $useCurrentTransaction;
18
19
  public function behaviors()
20
  {
21
    return CMap::mergeArray(
22
      parent::behaviors(),
23
      array(
24
        'currentTransactionBehavior' => array('class' => 'fronted.share.behaviors.CurrentTransactionBehavior')
25
      )
26
    );
27
  }
28
29 View Code Duplication
  public function beginTransaction()
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...
30
  {
31
    if( Yii::app()->db->getCurrentTransaction() && is_null($this->useCurrentTransaction) )
32
    {
33
      $this->useCurrentTransaction = false;
34
      return;
35
    }
36
37
    if( is_null($this->useCurrentTransaction) )
38
    {
39
      Yii::app()->db->beginTransaction();
40
      $this->useCurrentTransaction = true;
41
    }
42
  }
43
44
  public function commitTransaction()
45
  {
46
    if( $this->useCurrentTransaction )
47
    {
48
      Yii::app()->db->currentTransaction->commit();
49
      $this->useCurrentTransaction = null;
50
    }
51
  }
52
53
  public function rollbackTransaction()
54
  {
55
    if( $this->useCurrentTransaction )
56
    {
57
      Yii::app()->db->currentTransaction->rollback();
58
      $this->useCurrentTransaction = null;
59
    }
60
  }
61
}