Completed
Push — master ( 1add5f...99c403 )
by Dmitry
07:16
created

Entity::__debugInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Basis\Test;
4
5
use Basis\Test;
6
7
class Entity 
8
{
9
    public $id;
10
11
    private $_test;
12
    private $_key;
13
    
14
    public function __construct(Test $test, string $key)
15
    {
16
        $this->_test = $test;
17
        $this->_key = $key;
18
    }
19
20
    public function save()
21
    {
22
        if (!$this->id) {
23
            $max = 0;
24
            if (count($this->_test->data[$this->_key])) {
25
                $max = max(array_keys($this->_test->data[$this->_key]));
26
            }
27
            $this->id = $max + 1;
28
        }
29
        $this->_test->data[$this->_key][$this->id] = $this;
30
        return $this;
31
    }
32
33
    public function __debugInfo()
34
    {
35
        $info = get_object_vars($this);
36
        unset($info['_test']);
37
        unset($info['_key']);
38
        return $info;
39
    }
40
}
41