SegmentFactory::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
namespace Mailxpert\Model;
4
5
use Mailxpert\Exceptions\MailxpertSDKException;
6
7
/**
8
 * Class SegmentFactory
9
 * @package Mailxpert\Model
10
 */
11 View Code Duplication
class SegmentFactory 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...
12
{
13
    /**
14
     * @param mixed $data
15
     *
16
     * @return Segment|SegmentCollection
17
     * @throws MailxpertSDKException
18
     */
19
    public static function parse($data)
20
    {
21
        return parent::parse($data);
22
    }
23
24
    /**
25
     * @param $data
26
     *
27
     * @return SegmentCollection
28
     */
29
    protected static function buildCollection($data)
30
    {
31
        $segments = new SegmentCollection();
32
33
        foreach ($data as $segmentData) {
34
            $segment = static::buildElement($segmentData);
35
            $segments->add($segment);
36
        }
37
38
        return $segments;
39
    }
40
41
    /**
42
     * @param $data
43
     *
44
     * @return Segment
45
     */
46
    protected static function buildElement($data)
47
    {
48
        $segment = new Segment($data['id']);
49
        $segment->fromAPI($data);
50
51
        return $segment;
52
    }
53
}
54