Completed
Push — master ( 34ea5b...e94df2 )
by Pascal
13:41
created

Pokedex::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
namespace Atog\PHPokemon\Endpoints;
3
4
use Atog\Api\Endpoint;
5
6
/**
7
 * Class Pokedex
8
 * @package Atog\PHPokemon\Endpoints
9
 */
10
class Pokedex extends Endpoint
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $endpoint = 'pokedex';
16
17
    /**
18
     * @return \Atog\Api\Model|string
19
     */
20
    public function get()
21
    {
22
        $response = $this->client->get($this->getEndpointUrl(1, true));
23
24
        // return new model instance with fetched content if response is okay
25
        if ($response->isOk()) {
26
            return $this->model->newInstance($response->getContent());
0 ignored issues
show
Documentation introduced by
$response->getContent() is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
        }
28
29
        return $response->getContent();
30
    }
31
}
32