Cidades::getAll()   A
last analyzed

Complexity

Conditions 6
Paths 3

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 10
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 16
rs 9.2222
1
<?php
2
3
namespace CodePhix\Asaas;
4
5
6
class Cidades {
7
8
    public $http;
9
10
    public function __construct(Connection $connection)
11
    {
12
        $this->http = $connection;
13
    }
14
15
    // Retorna a listagem de cobranças
16
    public function getAll(array $filtros){
17
        $filtro = '';
18
        if(is_array($filtros)){
0 ignored issues
show
introduced by
The condition is_array($filtros) is always true.
Loading history...
19
            if($filtros){
0 ignored issues
show
Bug Best Practice introduced by
The expression $filtros of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
20
                foreach($filtros as $key => $f){
21
                    if(!empty($f)){
22
                        if($filtro){
23
                            $filtro .= '&';
24
                        }
25
                        $filtro .= $key.'='.$f;
26
                    }
27
                }
28
                $filtro = '?'.$filtro;
29
            }
30
        }
31
        return $this->http->get('/cities'.$filtro);
32
    }
33
34
    // Retorna os dados da cobrança de acordo com o Id
35
    public function getById($id){
36
        return $this->http->get('/cities/'.$id);
37
    }
38
39
}
40