RecurringApplicationChargeEndpoint   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 53
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A activate() 0 5 1
A findAll() 0 5 1
A findOne() 0 5 1
A create() 0 5 1
1
<?php
2
namespace CodeCloud\Bundle\ShopifyBundle\Api\Endpoint;
3
4
use CodeCloud\Bundle\ShopifyBundle\Api\Request\DeleteParams;
5
use CodeCloud\Bundle\ShopifyBundle\Api\Request\GetJson;
6
use CodeCloud\Bundle\ShopifyBundle\Api\Request\PostJson;
7
use CodeCloud\Bundle\ShopifyBundle\Api\GenericResource;
8
9
class RecurringApplicationChargeEndpoint extends AbstractEndpoint
10
{
11
    /**
12
     * @param \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource $recurringApplicationCharge
13
     * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource
14
     */
15
    public function create(GenericResource $recurringApplicationCharge)
16
    {
17
        $request = new PostJson('/admin/recurring_application_charges.json', array('recurring_application_charge' => $recurringApplicationCharge->toArray()));
18
        $response = $this->send($request);
19
        return $this->createEntity($response->get('recurring_application_charge'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('recurring_application_charge') can also be of type string; however, parameter $data of CodeCloud\Bundle\Shopify...ndpoint::createEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

19
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('recurring_application_charge'));
Loading history...
20
    }
21
22
    /**
23
     * @param int $recurringApplicationChargeId
24
     * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource
25
     */
26
    public function findOne($recurringApplicationChargeId)
27
    {
28
        $request = new GetJson('/admin/recurring_application_charges/' . $recurringApplicationChargeId . '.json');
29
        $response = $this->send($request);
30
        return $this->createEntity($response->get('recurring_application_charge'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('recurring_application_charge') can also be of type string; however, parameter $data of CodeCloud\Bundle\Shopify...ndpoint::createEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('recurring_application_charge'));
Loading history...
31
    }
32
33
    /**
34
     * @param array $query
35
     * @return array|GenericResource[]
36
     */
37
    public function findAll(array $query = array())
38
    {
39
        $request = new GetJson('/admin/recurring_application_charges.json', $query);
40
        $response = $this->send($request);
41
        return $this->createCollection($response->get('recurring_application_charges'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('recurring_application_charges') can also be of type string; however, parameter $items of CodeCloud\Bundle\Shopify...int::createCollection() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
        return $this->createCollection(/** @scrutinizer ignore-type */ $response->get('recurring_application_charges'));
Loading history...
42
    }
43
44
    /**
45
     * @param int $recurringApplicationChargeId
46
     * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource
47
     */
48
    public function activate($recurringApplicationChargeId)
49
    {
50
        $request = new PostJson('/admin/recurring_application_charges/' . $recurringApplicationChargeId . '/activate.json');
51
        $response = $this->send($request);
52
        return $this->createEntity($response->get('recurring_application_charge'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('recurring_application_charge') can also be of type string; however, parameter $data of CodeCloud\Bundle\Shopify...ndpoint::createEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

52
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('recurring_application_charge'));
Loading history...
53
    }
54
55
    /**
56
     * @param int $recurringApplicationChargeId
57
     */
58
    public function delete($recurringApplicationChargeId)
59
    {
60
        $request = new DeleteParams('/admin/recurring_application_charges/' . $recurringApplicationChargeId . '.json');
61
        $this->send($request);
62
    }
63
}
64