Category::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 1
eloc 8
c 3
b 0
f 1
nc 1
nop 0
dl 0
loc 13
rs 10
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 = ['id', 'name', 'parent_id'];
19
20
        $this->protectedVariables = ['prot_var', 'unloadable'];
21
    }
22
23
    protected function accessToProtectedVariable(string $name): bool
24
    {
25
        switch ($name) {
26
            case 'prot_var':
27
                $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...
28
                return true;
29
            case 'unloadable':
0 ignored issues
show
introduced by
The function implicitly returns null when this case condition does not match. This is incompatible with the type-hinted return boolean. Consider adding a default case to the switch.
Loading history...
30
                return false;
31
        }
32
    }
33
}
34