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

Pokedex   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 11 2
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