Completed
Push — work-fleets ( 0f036f...867546 )
by SuperNova.WS
06:49
created

EntityModel   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 47
ccs 0
cts 3
cp 0
rs 10
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * Class EntityModel
5
 *
6
 * @property int|float $dbId Buddy record DB ID
7
 */
8
class EntityModel implements \Common\IEntity {
9
//  /**
10
//   * Link to DB which used by this EntityModel
11
//   *
12
//   * @var db_mysql $dbStatic
13
//   * deprecated - replace with container ID like 'db' or 'dbAuth'
14
//   */
15
//  protected static $dbStatic;
16
17
  /**
18
   * Name of exception class that would be thrown
19
   *
20
   * Uses for calling when you don't know which exact exception should be called
21
   * On EntityModel's children should be used exception class name
22
   *
23
   * @var string $exceptionClass
24
   */
25
  protected static $exceptionClass = 'EntityException';
26
27
  /**
28
   * Container for property values
29
   *
30
   * @var \Common\IPropertyContainer $_container
31
   */
32
  protected $_container;
33
//  protected static $_containerName = 'V2PropertyContainer';
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
35
  /**
36
   * Service to work with rows
37
   *
38
   * @var \DbRowDirectOperator $rowOperator
39
   */
40
  protected static $rowOperator;
41
42
  /**
43
   * EntityModel constructor.
44
   *
45
   * @param \Common\GlobalContainer $gc
46
   */
47
  public function __construct($gc) {
48
//    empty(static::$dbStatic) && !empty($gc->db) ? static::$dbStatic = $gc->db : false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
49
    static::$rowOperator = $gc->dbRowOperator;
0 ignored issues
show
Documentation Bug introduced by
It seems like $gc->dbRowOperator can also be of type object<Closure>. However, the property $rowOperator is declared as type object<DbRowDirectOperator>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
50
  }
51
52
53
54
}
55