Code Duplication    Length = 40-69 lines in 2 locations

src/Binding/ClassBinding.php 1 location

@@ 25-93 (lines=69) @@
22
 *
23
 * @author Bernhard Schussek <[email protected]>
24
 */
25
class ClassBinding extends AbstractBinding
26
{
27
    /**
28
     * @var string
29
     */
30
    private $className;
31
32
    /**
33
     * Creates a new class binding.
34
     *
35
     * @param string $className       The fully-qualified name of the bound
36
     *                                class.
37
     * @param string $typeName        The name of the type to bind against.
38
     * @param array  $parameterValues The values of the parameters defined
39
     *                                for the type.
40
     *
41
     * @throws NoSuchParameterException  If an invalid parameter was passed.
42
     * @throws MissingParameterException If a required parameter was not passed.
43
     */
44
    public function __construct($className, $typeName, array $parameterValues = array())
45
    {
46
        parent::__construct($typeName, $parameterValues);
47
48
        $this->className = $className;
49
    }
50
51
    /**
52
     * Returns the name of the bound class.
53
     *
54
     * @return string The fully-qualified class name.
55
     */
56
    public function getClassName()
57
    {
58
        return $this->className;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function equals(Binding $other)
65
    {
66
        if (!parent::equals($other)) {
67
            return false;
68
        }
69
70
        /* @var ClassBinding $other */
71
        return $this->className === $other->className;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    protected function preSerialize(array &$data)
78
    {
79
        parent::preSerialize($data);
80
81
        $data[] = $this->className;
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    protected function postUnserialize(array &$data)
88
    {
89
        $this->className = array_pop($data);
90
91
        parent::postUnserialize($data);
92
    }
93
}
94

src/Test/Fixtures/StringBinding.php 1 location

@@ 24-63 (lines=40) @@
21
 *
22
 * @internal
23
 */
24
class StringBinding extends AbstractBinding
25
{
26
    private $string;
27
28
    public function __construct($string, $typeName, array $parameterValues = array())
29
    {
30
        parent::__construct($typeName, $parameterValues);
31
32
        $this->string = $string;
33
    }
34
35
    public function getString()
36
    {
37
        return $this->string;
38
    }
39
40
    public function equals(Binding $other)
41
    {
42
        if (!parent::equals($other)) {
43
            return false;
44
        }
45
46
        /* @var StringBinding $other */
47
        return $this->string === $other->string;
48
    }
49
50
    protected function preSerialize(array &$data)
51
    {
52
        parent::preSerialize($data);
53
54
        $data[] = $this->string;
55
    }
56
57
    protected function postUnserialize(array &$data)
58
    {
59
        $this->string = array_pop($data);
60
61
        parent::postUnserialize($data);
62
    }
63
}
64