Passed
Push — master ( f5c22c...929873 )
by Chris
16:12
created

ModelRepositoryInterfacePrinter::setupClass()   B

Complexity

Conditions 8
Paths 8

Size

Total Lines 27
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 72

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 8
eloc 19
c 2
b 0
f 2
nc 8
nop 1
dl 0
loc 27
ccs 0
cts 20
cp 0
crap 72
rs 8.4444
1
<?php
2
3
namespace Leonidas\Console\Library;
4
5
use Leonidas\Console\Library\Abstracts\AbstractModelRepositoryPrinter;
6
use Leonidas\Contracts\System\Model\FungibleRepositoryInterface;
7
use Leonidas\Contracts\System\Model\SoftDeletingRepositoryInterface;
8
use Nette\PhpGenerator\PhpNamespace;
9
10
class ModelRepositoryInterfacePrinter extends AbstractModelRepositoryPrinter
11
{
12
    protected function setupClass(PhpNamespace $namespace): object
13
    {
14
        $interface = $namespace
15
            ->addUse($this->model)
16
            ->addUse($this->collection)
17
            ->addInterface($this->class);
18
19
        switch ($this->template) {
20
            case 'post':
21
            case 'post:h':
22
            case 'attachment':
23
                $base = SoftDeletingRepositoryInterface::class;
24
25
                break;
26
27
            case 'term':
28
            case 'term:h':
29
            case 'user':
30
            case 'comment':
31
            default:
32
                $base = FungibleRepositoryInterface::class;
33
        }
34
35
        $namespace->addUse($base);
36
        $interface->setExtends($base);
37
38
        return $interface;
39
    }
40
}
41