Passed
Push — main ( 3feea0...902010 )
by Gabriel
14:42
created

Name::setController()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ByTIC\Namefy;
4
5
/**
6
 * Class Name
7
 * @package ByTIC\Namefy
8
 */
9
class Name
10
{
11
    protected $resource;
12
    protected $repository;
13
    protected $model;
14
    protected $controller;
15
16
    /**
17
     * @return mixed
18
     */
19
    public function resource()
20
    {
21
        $this->checkProperty('resource');
22
        return $this->resource;
23
    }
24
25
    /**
26
     * @param mixed $resource
27
     */
28
    public function setResource($resource): void
29
    {
30
        $this->resource = $resource;
31
    }
32
33
    /**
34
     * @return mixed
35
     */
36
    public function repository()
37
    {
38
        $this->checkProperty('repository');
39
        return $this->repository;
40
    }
41
42
    /**
43
     * @param mixed $repository
44
     */
45
    public function setRepository($repository): void
46
    {
47
        $this->repository = $repository;
48
    }
49
50
    /**
51
     * @return mixed
52
     */
53
    public function model()
54
    {
55
        $this->checkProperty('model');
56
        return $this->model;
57
    }
58
59
    /**
60
     * @param mixed $model
61
     */
62
    public function setModel($model): void
63
    {
64
        $this->model = $model;
65
    }
66
67
    /**
68
     * @return mixed
69
     */
70
    public function controller()
71
    {
72
        $this->checkProperty('controller');
73
        return $this->controller;
74
    }
75
76
    /**
77
     * @param mixed $controller
78
     */
79
    public function setController($controller): void
80
    {
81
        $this->controller = $controller;
82
    }
83
84
    /**
85
     * @param string $name
86
     */
87
    protected function checkProperty($name)
88
    {
89
        if (isset($this->{$name}) && $this->{$name} instanceof \Closure) {
90
            $this->{$name} = ($this->{$name})();
91
        }
92
    }
93
}
94