BackwardCompatibleMethodsTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 56
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 5 1
A setMethod() 0 6 1
A setConstructArgs() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of Di
5
 *
6
 * For the full copyright and license information, please view the LICENSE.md
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Di\Definition;
11
12
/**
13
 * Backward Compatible Methods Trait
14
 *
15
 * @see https://github.com/slickframework/di/issues/1
16
 *
17
 * @package Slick\Di\Definition
18
 * @author  Filipe Silva <[email protected]>
19
 */
20
trait BackwardCompatibleMethodsTrait
21
{
22
23
    /**
24
     * Sets constructor arguments used on instance instantiation
25
     *
26
     * @param array $arguments
27
     * @return $this|self
28
     *
29
     * @deprecated You should use ObjectDefinition::withConstructorArgument().
30
     *             This will be removed in the next major release.
31
     */
32
    public function setConstructArgs(array $arguments)
33
    {
34
        return call_user_func_array(
35
            [$this, 'withConstructorArgument'],
36
            $arguments
37
        );
38
    }
39
40
    /**
41
     * Set a method to be called when resolving this definition
42
     *
43
     * @param string $name      Method name
44
     * @param array  $arguments Method parameters
45
     *
46
     * @return $this|self
47
     *
48
     * @deprecated You should use ObjectDefinition::callMethod(). This
49
     *             will be removed in the next major release.
50
     */
51
    public function setMethod($name, array $arguments = [])
52
    {
53
        $arguments = array_merge([$name], $arguments);
54
        return call_user_func_array(
55
            [$this, 'callMethod'],
56
            $arguments
57
        );
58
    }
59
60
    /**
61
     * Sets property value when resolving this definition
62
     *
63
     * @param string $name  The property name
64
     * @param mixed  $value The property value
65
     *
66
     * @return $this|self
67
     *
68
     * @deprecated You should use ObjectDefinition::assignProperty(). This
69
     *             will be removed in the next major release.
70
     */
71
    public function setProperty($name, $value)
72
    {
73
        return call_user_func_array(
74
            [$this, 'assignProperty'],
75
            [$name, $value]
76
        );
77
    }
78
}
79