ModelRepositoryInterfacePrinter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 20
c 0
b 0
f 0
dl 0
loc 29
ccs 0
cts 20
cp 0
rs 10
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B setupClass() 0 27 8
1
<?php
2
3
namespace Leonidas\Console\Library\Printer\Model;
4
5
use Leonidas\Console\Library\Printer\Model\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