Passed
Push — master ( f107f9...34b1fd )
by Max Alex
01:49
created

Cidades::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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