UserEndpoint   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findOne() 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\GetJson;
5
6
class UserEndpoint extends AbstractEndpoint
7
{
8
    /**
9
     * @return array|GenericEntity[]
10
     */
11
    public function findAll()
12
    {
13
        $request = new GetJson('/admin/users.json');
14
        $response = $this->send($request);
15
        return $this->createCollection($response->get('users'));
0 ignored issues
show
Bug introduced by
It seems like $response->get('users') 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

15
        return $this->createCollection(/** @scrutinizer ignore-type */ $response->get('users'));
Loading history...
16
    }
17
18
    /**
19
     * @param int $userId
20
     * @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...
21
     */
22
    public function findOne($userId)
23
    {
24
        $request = new GetJson('/admin/users/' . $userId . '.json');
25
        $response = $this->send($request);
26
        return $this->createEntity($response->get('user'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createEnti...$response->get('user')) 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('user') 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

26
        return $this->createEntity(/** @scrutinizer ignore-type */ $response->get('user'));
Loading history...
27
    }
28
}
29