@@ 14-56 (lines=43) @@ | ||
11 | * Class ContactFactory |
|
12 | * @package Mailxpert\Model |
|
13 | */ |
|
14 | class ContactFactory extends Factory |
|
15 | { |
|
16 | /** |
|
17 | * @param mixed $data |
|
18 | * |
|
19 | * @return Contact|ContactCollection |
|
20 | * @throws MailxpertSDKException |
|
21 | */ |
|
22 | public static function parse($data) |
|
23 | { |
|
24 | return parent::parse($data); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * @param $data |
|
29 | * |
|
30 | * @return ContactCollection |
|
31 | */ |
|
32 | protected static function buildCollection($data) |
|
33 | { |
|
34 | $contacts = new ContactCollection(); |
|
35 | ||
36 | foreach ($data as $contactData) { |
|
37 | $contact = static::buildElement($contactData); |
|
38 | $contacts->add($contact); |
|
39 | } |
|
40 | ||
41 | return $contacts; |
|
42 | } |
|
43 | ||
44 | /** |
|
45 | * @param $data |
|
46 | * |
|
47 | * @return Contact |
|
48 | */ |
|
49 | protected static function buildElement($data) |
|
50 | { |
|
51 | $contact = new Contact($data['email'], $data['id']); |
|
52 | $contact->fromAPI($data); |
|
53 | ||
54 | return $contact; |
|
55 | } |
|
56 | } |
|
57 |
@@ 12-54 (lines=43) @@ | ||
9 | * Class CustomFieldChoiceFactory |
|
10 | * @package Mailxpert\Model |
|
11 | */ |
|
12 | class CustomFieldChoiceFactory extends Factory |
|
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 |
@@ 12-54 (lines=43) @@ | ||
9 | * Class CustomFieldFactory |
|
10 | * @package Mailxpert\Model |
|
11 | */ |
|
12 | class CustomFieldFactory extends Factory |
|
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 |
@@ 11-53 (lines=43) @@ | ||
8 | * Class SegmentFactory |
|
9 | * @package Mailxpert\Model |
|
10 | */ |
|
11 | class SegmentFactory extends Factory |
|
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 |