Completed
Push — master ( 2a6a78...c2b2ef )
by DELEVOYE
05:24
created

MindbazSerializationVisitor::getResult()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 2
nop 0
crap 12
1
<?php
2
3
/*
4
 * This file is part of the MindbazBundle package.
5
 *
6
 * (c) David DELEVOYE <[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 Kozikaza\MindbazBundle\Serializer\Bridge\Visitor;
13
14
use JMS\Serializer\GenericSerializationVisitor;
15
use Kozikaza\MindbazBundle\Serializer\SubscriberEncoder;
16
use mbzSubscriber\Subscriber;
17
use mbzSubscriber\SubscriberFieldData;
18
19
/**
20
 * @author Vincent Chalamon <[email protected]>
21
 */
22
class MindbazSerializationVisitor extends GenericSerializationVisitor
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27 View Code Duplication
    public function getResult()
0 ignored issues
show
Duplication introduced by
This method 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...
28
    {
29
        $data = $this->getRoot();
30
        $fld = [];
31
        foreach ($data as $key => $value) {
32
            $fld[] = (new SubscriberFieldData(SubscriberEncoder::FIELDS[$key]))->setValue($value);
33
        }
34
35
        $subscriber = new Subscriber(isset($data['id']) ? $data['id'] : -1);
36
        $subscriber->setFld($fld);
37
38
        return $subscriber;
39
    }
40
}
41