CustomFieldChoiceFactory::buildElement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 7
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Date: 21/08/15
4
 */
5
6
namespace Mailxpert\Model;
7
8
/**
9
 * Class CustomFieldChoiceFactory
10
 * @package Mailxpert\Model
11
 */
12 View Code Duplication
class CustomFieldChoiceFactory extends Factory
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...
13
{
14
    /**
15
     * @param mixed $data
16
     *
17
     * @return CustomFieldChoice|CustomFieldChoiceCollection
18
     * @throws \Mailxpert\Exceptions\MailxpertSDKException
19
     */
20
    public static function parse($data)
21
    {
22
        return parent::parse($data);
23
    }
24
25
    /**
26
     * @param $data
27
     *
28
     * @return CustomFieldChoiceCollection
29
     */
30
    protected static function buildCollection($data)
31
    {
32
        $customFieldChoices = new CustomFieldChoiceCollection();
33
34
        foreach ($data as $customFieldChoiceData) {
35
            $customFieldChoice = static::buildElement($customFieldChoiceData);
36
            $customFieldChoices ->add($customFieldChoice);
37
        }
38
39
        return $customFieldChoices;
40
    }
41
42
    /**
43
     * @param $data
44
     *
45
     * @return CustomFieldChoice
46
     */
47
    protected static function buildElement($data)
48
    {
49
        $customFieldChoice = new CustomFieldChoice($data['alias'], $data['id']);
50
        $customFieldChoice->fromAPI($data);
51
52
        return $customFieldChoice;
53
    }
54
}
55