Completed
Pull Request — master (#7)
by Rafael
03:49
created

PartnerClient   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 0 Features 1
Metric Value
wmc 8
c 6
b 0
f 1
lcom 1
cbo 1
dl 0
loc 105
ccs 37
cts 37
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createOrderOnVenture() 0 17 2
A cancelOrderOnVenture() 0 16 2
A confirmPaymentOnVenture() 0 16 2
A sendProductCreationConfirmationToVenture() 0 20 2
1
<?php
2
3
namespace Iris\Api;
4
5
class PartnerClient extends BaseClient
6
{
7
    /**
8
     * Partner Create Order on External Shop
9
     *
10
     * @param string $ventureCode
11
     * @param array $orderData
12
     * @return bool
13
     */
14 2
    public function createOrderOnVenture($ventureCode, $orderData)
15
    {
16
        try {
17 2
            $this->doRequest(
18 2
                'post',
19 2
                $this->buildRequestUrl('/fulfillment/order/create', $ventureCode),
20 2
                array('body' => json_encode($orderData))
21 2
            );
22 2
        } catch (\Exception $e) {
23 1
            $this->throwException(
24 1
                $e,
25 1
                'Unable to create order on Externalshop',
26 1
                ['VentureCode' => $ventureCode, 'OrderData' => $orderData]
27 1
            );
28
        }
29 2
        return true;
30
    }
31
32
33
    /**
34
     * Partner Confirm Paid Order on External Shop
35
     *
36
     * @param string $ventureCode
37
     * @param int    $orderNr
38
     * @return bool
39 2
     */
40
    public function confirmPaymentOnVenture($ventureCode, $orderNr)
41
    {
42 2
        try {
43 2
            $this->doRequest(
44 2
                'put',
45 2
                $this->buildRequestUrl(sprintf('/fulfillment/order/confirm/%s', $orderNr), $ventureCode)
46 2
            );
47 1
        } catch (\Exception $e) {
48 1
            $this->throwException(
49 1
                $e,
50 1
                'Unable to confirm payment for venture on Externalshop',
51 1
                ['VentureCode' => $ventureCode, 'OrderNr' => $orderNr]
52
            );
53 2
        }
54
        return true;
55
    }
56
57
    /**
58
     * Partner Cancel Order on External Shop
59
     *
60
     * @param string $ventureCode
61
     * @param int    $orderNr
62
     * @return bool
63 2
     */
64
    public function cancelOrderOnVenture($ventureCode, $orderNr)
65
    {
66 2
        try {
67 2
            $this->doRequest(
68 2
                'put',
69 2
                $this->buildRequestUrl(sprintf('/fulfillment/order/cancel/%s', $orderNr), $ventureCode)
70 2
            );
71 1
        } catch (\Exception $e) {
72 1
            $this->throwException(
73 1
                $e,
74 1
                'Unable to cancel order on Externalshop',
75 1
                ['VentureCode' => $ventureCode, 'OrderNr' => $orderNr]
76
            );
77 2
        }
78
        return true;
79
    }
80
81
    //products
82
    /**
83
     * Sends product creation status to venture
84
     *
85
     * @param array $productsData
86
     * @param string $venture
0 ignored issues
show
Documentation introduced by
There is no parameter named $venture. Did you maybe mean $ventureCode?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
87
     * @return void
88
     */
89
    public function sendProductCreationConfirmationToVenture(
90
        array $productsData,
91
        $ventureCode
92
    ) {
93
94
        try {
95
            $this->doRequest(
96
                'post',
97
                $this->buildRequestUrl('/products/create/confirm', $ventureCode),
98
                array('body' => json_encode($productsData))
99
            );
100
        } catch (\Exception $e) {
101
            $this->throwException(
102
                $e,
103
                'Unable to send product creation status to Externalshop',
104
                ['VentureCode' => $ventureCode, 'ConfigData' => $productsData]
105
            );
106
        }
107
        return true;
108
    }
109
}
110