TableRegistryTrait::getTable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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