Completed
Push — master ( 6f9361...424eb0 )
by Evan
11:41
created

ProductGateway   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 44.44%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 4
c 4
b 1
f 0
lcom 0
cbo 3
dl 0
loc 43
ccs 8
cts 18
cp 0.4444
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProductGroupsWithProducts() 0 17 3
A getCreditInfo() 0 9 1
1
<?php
2
/*
3
* This file is part of the PayBreak/basket package.
4
*
5
* (c) PayBreak <[email protected]>
6
*
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
9
*/
10
11
namespace PayBreak\Sdk\Gateways;
12
use PayBreak\Sdk\Entities\GroupEntity;
13
use PayBreak\Sdk\Entities\ProductEntity;
14
15
/**
16
 * Product Gateway
17
 *
18
 * @author EB
19
 * @package PayBreak\Sdk\Gateways
20
 */
21
class ProductGateway extends AbstractGateway
22
{
23
    /**
24
     * @param string $extId
25
     * @param string $token
26
     * @return GroupEntity
27
     */
28 2
    public function getProductGroupsWithProducts($extId, $token)
29
    {
30 2
        $response = $this->fetchDocument(
31 2
                '/v4/installations/' . $extId . '/product-groups?with=products',
32 2
                $token,
33
                'listGroupsWithProducts'
34 2
        );
35
36 2
        foreach($response as &$group) {
37
            foreach($group['products'] as &$product) {
38
                $product = ProductEntity::make($product);
39
            }
40
            $group = GroupEntity::make($group);
41 2
        }
42
43 2
        return $response;
44
    }
45
46
    /**
47
     * @author WN
48
     * @param string $installation
49
     * @param string $product
50
     * @param string $token
51
     * @param array $params
52
     * @return array
53
     */
54
    public function getCreditInfo($installation, $product, $token, array $params)
55
    {
56
        return $this->postDocument(
57
            '/v4/installations/' . $installation . '/products/' . $product . '/get-credit-information',
58
            $params,
59
            $token,
60
            'CreditInfo'
61
        );
62
    }
63
}
64