Completed
Push — master ( c30a0b...37c0e6 )
by Nate
08:20
created

TransformResponseErrorsTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transformResponseErrors() 0 14 1
1
<?php
2
3
/**
4
 * @noinspection PhpUnusedParameterInspection
5
 *
6
 * @copyright  Copyright (c) Flipbox Digital Limited
7
 * @license    https://flipboxfactory.com/software/hubspot/license
8
 * @link       https://www.flipboxfactory.com/software/hubspot/
9
 */
10
11
namespace flipbox\craft\hubspot\transformers;
12
13
use Psr\Http\Message\ResponseInterface;
14
use yii\base\DynamicModel;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
trait TransformResponseErrorsTrait
21
{
22
    /**
23
     * @param ResponseInterface $response
24
     * @param array $data
25
     * @return DynamicModel
26
     */
27
    protected function transformResponseErrors(ResponseInterface $response, array $data): DynamicModel
28
    {
29
        $errors = call_user_func_array(
30
            new InterpretResponseErrors(),
31
            [
32
                $data
33
            ]
34
        );
35
36
        $model = new DynamicModel();
37
        $model->addErrors($errors);
38
39
        return $model;
40
    }
41
}
42