CustomFieldFactory::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 CustomFieldFactory
10
 * @package Mailxpert\Model
11
 */
12 View Code Duplication
class CustomFieldFactory 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 CustomField|CustomFieldCollection
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 CustomFieldCollection
29
     */
30
    protected static function buildCollection($data)
31
    {
32
        $customFields = new CustomFieldCollection();
33
34
        foreach ($data as $customFieldData) {
35
            $customField = static::buildElement($customFieldData);
36
            $customFields ->add($customField);
37
        }
38
39
        return $customFields;
40
    }
41
42
    /**
43
     * @param $data
44
     *
45
     * @return CustomField
46
     */
47
    protected static function buildElement($data)
48
    {
49
        $customField = new CustomField($data['alias'], $data['id']);
50
        $customField->fromAPI($data);
51
52
        return $customField;
53
    }
54
}
55