TableRegistryTrait::setRegistry()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 2
nop 1
crap 12
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