Completed
Push — develop ( cba78f...09bcdb )
by Nicolas
12:47
created

Proxy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace devtransition\jobbers;
4
5
use devtransition\jobbers\helper\DocBlock;
6
use yii\helpers\VarDumper;
7
8
class Proxy
9
{
10
    private $_class;
11
    private $_method;
12
    private $_args;
13
14
    private $_reflector;
0 ignored issues
show
Unused Code introduced by
The property $_reflector is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
15
    private $_defaults;
16
17
    /**
18
     * @param $class
19
     */
20
    public function __construct(&$class)
21
    {
22
        $this->_class = $class;
23
    }
24
25
    public function __call($name, $arguments)
26
    {
27
        $this->_method = $name;
28
        $this->_args = $arguments;
29
30
        $this->_prepareDefaults();
31
32
        return new Job($this);
33
    }
34
35
    public function getClass()
36
    {
37
        return $this->_class;
38
    }
39
40
    public function getMethod()
41
    {
42
        return $this->_method;
43
    }
44
45
    public function getArgs()
46
    {
47
        return $this->_args;
48
    }
49
50
    public function getDefaults()
51
    {
52
        return $this->_defaults;
53
    }
54
55
    private function _prepareDefaults()
56
    {
57
        $helper = new DocBlock($this->_class);
58
59
        $this->_defaults = array_merge(
60
            Jobbers::getInstance()->getConfig(),
61
            $helper->getClassOptions(),
62
            $helper->getMethodOptions($this->_method)
63
        );
64
    }
65
66
}