Entity   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 70.59%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 34
ccs 12
cts 17
cp 0.7059
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A save() 0 12 3
A __debugInfo() 0 7 1
1
<?php
2
3
namespace Basis\Test;
4
5
use Basis\Test;
6
use Tarantool\Mapper\Entity as MapperEntity;
7
8
class Entity extends MapperEntity
9
{
10
    public $id;
11
12
    private $_test;
13
    private $_key;
14
    
15 2
    public function __construct(Test $test, string $key)
16
    {
17 2
        $this->_test = $test;
18 2
        $this->_key = $key;
19 2
    }
20
21 2
    public function save() : MapperEntity
22
    {
23 2
        if (!$this->id) {
24 2
            $max = 0;
25 2
            if (count($this->_test->data[$this->_key])) {
26 2
                $max = max(array_keys($this->_test->data[$this->_key]));
27
            }
28 2
            $this->id = $max + 1;
29
        }
30 2
        $this->_test->data[$this->_key][$this->id] = $this;
31 2
        return $this;
32
    }
33
34
    public function __debugInfo()
35
    {
36
        $info = parent::__debugInfo();
37
        unset($info['_test']);
38
        unset($info['_key']);
39
        return $info;
40
    }
41
}
42