Passed
Push — develop ( 5cbd49...d5f7f5 )
by Mathieu
01:43
created

Category   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 23
dl 0
loc 36
rs 10
c 3
b 0
f 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A accessToProtectedVariable() 0 9 3
A __construct() 0 19 1
1
<?php
2
3
class Category extends \Suricate\DBObject
4
{
5
    protected $tableName = 'categories';
6
    protected $tableIndex = 'id';
7
8
    public function __construct()
9
    {
10
        parent::__construct();
11
        $database = new \Suricate\Database();
12
        $database->configure([
13
            'type' => 'sqlite',
14
            'file' => '/tmp/test.db',
15
        ]);
16
        $this->dbLink = $database;
17
18
        $this->dbVariables = [
19
            'id',
20
            'name',
21
            'parent_id',
22
        ];
23
24
        $this->protectedVariables = [
25
            'prot_var',
26
            'unloadable',
27
        ];
28
    }
29
30
    protected function accessToProtectedVariable($name)
31
    {
32
        switch ($name) {
33
            case 'prot_var':
34
                $this->prot_var = 42;
0 ignored issues
show
Bug Best Practice introduced by
The property prot_var does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
                return true;
36
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
37
            case 'unloadable':
38
                return false;
39
        }
40
    }
41
}
42