TableRegistryTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 27
c 0
b 0
f 0
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setRegistry() 0 8 3
A getTable() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Cake\Orm;
4
5
use Cake\ORM\TableRegistry;
6
7
trait TableRegistryTrait
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $registry = TableRegistry::class;
13
14
    /**
15
     * @param string $registry
16
     */
17
    public function setRegistry($registry)
18
    {
19
        if ($registry !== TableRegistry::class && $registry !== AsyncTableRegistry::class) {
20
            throw new \InvalidArgumentException('Not a AsyncTableRegistry or TableRegistry');
21
        }
22
23
        $this->registry = $registry;
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function getTable()
30
    {
31
        return call_user_func_array($this->registry . '::get', func_get_args());
32
    }
33
}
34