StringBinding::equals()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
ccs 0
cts 4
cp 0
rs 9.6666
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of the puli/discovery package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Discovery\Test\Fixtures;
13
14
use Puli\Discovery\Api\Binding\Binding;
15
use Puli\Discovery\Binding\AbstractBinding;
16
17
/**
18
 * @since  1.0
19
 *
20
 * @author Bernhard Schussek <[email protected]>
21
 *
22
 * @internal
23
 */
24 View Code Duplication
class StringBinding extends AbstractBinding
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
    private $string;
27
28 97
    public function __construct($string, $typeName, array $parameterValues = array())
29
    {
30 97
        parent::__construct($typeName, $parameterValues);
31
32 97
        $this->string = $string;
33 97
    }
34
35
    public function getString()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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 69
    protected function preSerialize(array &$data)
51
    {
52 69
        parent::preSerialize($data);
53
54 69
        $data[] = $this->string;
55 69
    }
56
57 26
    protected function postUnserialize(array &$data)
58
    {
59 26
        $this->string = array_pop($data);
60
61 26
        parent::postUnserialize($data);
62 26
    }
63
}
64