CustomFieldsHelper::loadChoices()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 2
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * Date: 21/08/15
4
 */
5
6
namespace Mailxpert\Helpers;
7
8
use Mailxpert\Mailxpert;
9
use Mailxpert\Model\CustomFieldCollection;
10
use Mailxpert\Request\CustomFieldsChoicesRequest;
11
12
/**
13
 * Class CustomFieldsHelper
14
 * @package Mailxpert\Helpers
15
 */
16
class CustomFieldsHelper
17
{
18
    /**
19
     * @param Mailxpert             $mailxpert
20
     * @param CustomFieldCollection $customFields
21
     */
22
    public static function loadChoices(Mailxpert $mailxpert, CustomFieldCollection $customFields)
23
    {
24
        foreach ($customFields as $customField) {
25
            if (in_array($customField->getType(), ['choice', 'choice_multiple', 'choice_expanded'])) {
26
                $response = CustomFieldsChoicesRequest::get($mailxpert, $customField->getId());
27
28
                $customField->setChoices($response->getMailxpertNode());
29
            }
30
        }
31
    }
32
}
33