Issues (193)

src/Api/Endpoint/OrderRisksEndpoint.php (5 issues)

Labels
Severity
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 OrderRisksEndpoint extends AbstractEndpoint
11
{
12
    /**
13
     * @param int $orderId
14
     * @return array|GenericResource
15
     */
16
    public function findByOrder($orderId)
17
    {
18
        $request = new GetJson('/admin/orders/' . $orderId . '/risks.json');
19
        $response = $this->send($request);
20
        return $this->createCollection($response->get('risks'));
0 ignored issues
show
It seems like $response->get('risks') 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('risks'));
Loading history...
21
    }
22
23
    /**
24
     * @param int $orderId
25
     * @param int $orderRisksId
26
     * @return GenericResource
27
     */
28
    public function findOne($orderId, $orderRisksId)
29
    {
30
        $request = new GetJson('/admin/orders/' . $orderId . '/risks/' . $orderRisksId . '.json');
31
        $response = $this->send($request);
32
        return $this->createEntity($response->get('risk'));
0 ignored issues
show
It seems like $response->get('risk') 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

32
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('risk'));
Loading history...
33
    }
34
35
    /**
36
     * @param int $orderId
37
     * @param GenericResource $orderRisks
38
     * @return GenericResource
39
     */
40
    public function create($orderId, GenericResource $orderRisks)
41
    {
42
        $request = new PostJson('/admin/orders/' . $orderId . '/risks.json', $orderRisks);
0 ignored issues
show
$orderRisks of type CodeCloud\Bundle\ShopifyBundle\Api\GenericResource is incompatible with the type array|string expected by parameter $postData of CodeCloud\Bundle\Shopify...PostJson::__construct(). ( Ignorable by Annotation )

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

42
        $request = new PostJson('/admin/orders/' . $orderId . '/risks.json', /** @scrutinizer ignore-type */ $orderRisks);
Loading history...
43
        $response = $this->send($request);
44
        return $this->createEntity($response->get('risk'));
0 ignored issues
show
It seems like $response->get('risk') 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

44
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('risk'));
Loading history...
45
    }
46
47
    /**
48
     * @param int $orderId
49
     * @param int $orderRisksId
50
     * @param GenericResource $orderRisks
51
     * @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource
52
     */
53
    public function update($orderId, $orderRisksId, GenericResource $orderRisks)
54
    {
55
        $request = new PutJson('/admin/orders/' . $orderId . '/risks/' . $orderRisksId . '.json', array('risk' => $orderRisks->toArray()));
56
        $response = $this->send($request);
57
        return $this->createEntity($response->get('risk'));
0 ignored issues
show
It seems like $response->get('risk') 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

57
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('risk'));
Loading history...
58
    }
59
60
    /**
61
     * @param int $orderId
62
     * @param int $orderRisksId
63
     */
64
    public function delete($orderId, $orderRisksId)
65
    {
66
        $request = new DeleteParams('/admin/orders/' . $orderId . '/risks/' . $orderRisksId . '.json');
67
        $this->send($request);
68
    }
69
}
70