Completed
Push — master ( 7e02e6...ea0e93 )
by wen
03:01
created

View   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 47
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setRepository() 0 6 1
A getRepository() 0 4 1
A getWith() 0 4 1
A with() 0 6 1
A toArray() 0 4 1
1
<?php
2
3
namespace Sco\Admin\View;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use Sco\Admin\Contracts\RepositoryInterface;
7
use Sco\Admin\Contracts\ViewInterface;
8
9
abstract class View implements ViewInterface, Arrayable
10
{
11
    /**
12
     * @var array
13
     */
14
    protected $with = [];
15
16
    /**
17
     * @var RepositoryInterface
18
     */
19
    protected $repository;
20
21
    public function setRepository(RepositoryInterface $repository)
22
    {
23
        $this->repository = $repository;
24
        $this->repository->with($this->getWith());
25
        return $this;
26
    }
27
28
    public function getRepository()
29
    {
30
        return $this->repository;
31
    }
32
33
    /**
34
     * @return string[]
35
     */
36
    public function getWith()
37
    {
38
        return $this->with;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function with($relations)
45
    {
46
        $this->with = array_flatten(func_get_args());
47
48
        return $this;
49
    }
50
51
    public function toArray()
52
    {
53
        return [];
54
    }
55
}
56