prepareValidationErrors()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\craft\hubspot\transformers;
10
11
use flipbox\craft\ember\helpers\ArrayHelper;
12
13
/**
14
 * @author Flipbox Factory <[email protected]>
15
 * @since 1.0.0
16
 */
17
trait UpsertErrorInterpreterTrait
18
{
19
    /**
20
     * @param array $errors
21
     * @return array
22
     */
23
    protected function prepareValidationErrors(array $errors): array
24
    {
25
        $validationErrors = [];
26
27
        foreach ($errors as $error) {
28
            if ($property = ArrayHelper::getValue($error, 'name')) {
29
                $validationErrors[$property] = ArrayHelper::getValue($error, 'message');
30
            }
31
        }
32
33
        return $validationErrors;
34
    }
35
}
36