IdentifierToObjectTransformer::transform()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 1
1
<?php
2
3
namespace DoS\ResourceBundle\Form\DataTransformer;
4
5
use Doctrine\Common\Persistence\ObjectRepository;
6
use Sylius\Bundle\ResourceBundle\Form\DataTransformer\ObjectToIdentifierTransformer;
7
8
/**
9
 * Object to id transformer.
10
 */
11
class IdentifierToObjectTransformer extends ObjectToIdentifierTransformer
12
{
13
    /**
14
     * Repository.
15
     *
16
     * @var ObjectRepository
17
     */
18
    protected $repository;
19
20
    /**
21
     * Identifier.
22
     *
23
     * @var string
24
     */
25
    protected $identifier;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param ObjectRepository $repository
31
     * @param string           $identifier
32
     */
33
    public function __construct(ObjectRepository $repository, $identifier = 'id')
34
    {
35
        $this->repository = $repository;
36
        $this->identifier = $identifier;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function reverseTransform($value)
43
    {
44
        return parent::transform($value);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (transform() instead of reverseTransform()). Are you sure this is correct? If so, you might want to change this to $this->transform().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function transform($value)
51
    {
52
        return parent::reverseTransform($value);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (reverseTransform() instead of transform()). Are you sure this is correct? If so, you might want to change this to $this->reverseTransform().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
53
    }
54
}
55