EventEndpoint::countAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
namespace CodeCloud\Bundle\ShopifyBundle\Api\Endpoint;
3
4
use CodeCloud\Bundle\ShopifyBundle\Api\Request\GetJson;
5
6
class EventEndpoint extends AbstractEndpoint
7
{
8
    /**
9
     * @param array $query
10
     * @return array|GenericEntity[]
11
     */
12
    public function findAll(array $query = array())
13
    {
14
        $request = new GetJson('/admin/events.json', $query);
15
        $response = $this->sendPaged($request, 'events');
16
        return $this->createCollection($response);
17
    }
18
19
    /**
20
     * @param array $query
21
     * @return int
22
     */
23
    public function countAll(array $query = array())
24
    {
25
        $request = new GetJson('/admin/events/count.json', $query);
26
        $response = $this->send($request);
27
        return $response->get('count');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $response->get('count') also could return the type string which is incompatible with the documented return type integer.
Loading history...
28
    }
29
30
    /**
31
     * @param int $eventId
32
     * @return GenericEntity
0 ignored issues
show
Bug introduced by
The type CodeCloud\Bundle\Shopify...\Endpoint\GenericEntity was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
     */
34
    public function findOne($eventId)
35
    {
36
        $request = new GetJson('/admin/events/' . $eventId . '.json');
37
        $response = $this->send($request);
38
        return $this->createEntity($response->get('event'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createEnti...response->get('event')) returns the type CodeCloud\Bundle\ShopifyBundle\Api\GenericResource which is incompatible with the documented return type CodeCloud\Bundle\Shopify...\Endpoint\GenericEntity.
Loading history...
Bug introduced by
It seems like $response->get('event') 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

38
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('event'));
Loading history...
39
    }
40
}
41