FulfillmentServiceEndpoint   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A findOne() 0 5 1
A update() 0 5 1
A delete() 0 4 1
A create() 0 5 1
A findAll() 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\Request\PutJson;
8
use CodeCloud\Bundle\ShopifyBundle\Api\GenericResource;
9
10
class FulfillmentServiceEndpoint extends AbstractEndpoint
11
{
12
    /**
13
     * @param array $query
14
     * @return array|GenericResource[]
15
     */
16
    public function findAll(array $query = array('scope' => 'all'))
17
    {
18
        $request = new GetJson('/admin/fulfillment_services.json', $query);
19
        $response = $this->send($request);
20
        return $this->createCollection($response->get('fulfillment_services'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('fulfillment_services') 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

20
        return $this->createCollection(/** @scrutinizer ignore-type */ $response->get('fulfillment_services'));
Loading history...
21
    }
22
23
    /**
24
     * @param int $fulfillmentServiceId
25
     * @return GenericResource
26
     */
27
    public function findOne($fulfillmentServiceId)
28
    {
29
        $request = new GetJson('/admin/fulfillment_services/' . $fulfillmentServiceId . '.json');
30
        $response = $this->send($request);
31
        return $this->createEntity($response->get('fulfillment_service'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('fulfillment_service') 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

31
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('fulfillment_service'));
Loading history...
32
    }
33
34
    /**
35
     * @param GenericResource $fulfillmentService
36
     * @return GenericResource
37
     */
38
    public function create(GenericResource $fulfillmentService)
39
    {
40
        $request = new PostJson('/admin/fulfillment_services.json', array('fulfillment_service' => $fulfillmentService->toArray()));
41
        $response = $this->send($request);
42
        return $this->createEntity($response->get('fulfillment_service'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('fulfillment_service') 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

42
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('fulfillment_service'));
Loading history...
43
    }
44
45
    /**
46
     * @param int $fulfillmentServiceId
47
     * @param GenericResource $fulfillmentService
48
     * @return GenericResource
49
     */
50
    public function update($fulfillmentServiceId, GenericResource $fulfillmentService)
51
    {
52
        $request = new PutJson('/admin/fulfillment_services/' . $fulfillmentServiceId . '.json', array('fulfillment_service' => $fulfillmentService->toArray()));
53
        $response = $this->send($request);
54
        return $this->createEntity($response->get('fulfillment_service'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('fulfillment_service') 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

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