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

Notificacao::getById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CodePhix\Asaas;
4
5
6
class Notificacao {
7
    //
8
9
    public $http;
10
11
    public function __construct(Connection $connection)
12
    {
13
        $this->http = $connection;
14
    }
15
16
    // Retorna a listagem de notificações
17
    public function getAll(array $filtros){
18
        $filtro = '';
19
        if(is_array($filtros)){
0 ignored issues
show
introduced by
The condition is_array($filtros) is always true.
Loading history...
20
            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...
21
                foreach($filtros as $key => $f){
22
                    if(!empty($f)){
23
                        if($filtro){
24
                            $filtro .= '&';
25
                        }
26
                        $filtro .= $key.'='.$f;
27
                    }
28
                }
29
                $filtro = '?'.$filtro;
30
            }
31
        }
32
        return $this->http->get('/notifications'.$filtro);
33
    }
34
    
35
    // Retorna os dados da notificação de acordo com o Id
36
    public function getById($id){
37
        return $this->http->get('/notifications/'.$id);
38
    }
39
    
40
    // Retorna a listagem de notificações de acordo com o Id do Cliente
41
    public function getByCustomer($customer_id){
0 ignored issues
show
Unused Code introduced by
The parameter $customer_id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
    public function getByCustomer(/** @scrutinizer ignore-unused */ $customer_id){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
        return $this->http->get('/customers/'.$id.'/notifications');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $id seems to be never defined.
Loading history...
43
    }
44
    
45
    // Insere uma nova notificação
46
    public function create(array $dadosNotificacao){
47
        return $this->http->post('/notifications', $dadosNotificacao);
48
    }
49
    
50
    // Atualiza os dados da notificação
51
    public function update($id, array $dadosNotificacao){
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

51
    public function update(/** @scrutinizer ignore-unused */ $id, array $dadosNotificacao){

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
        return $this->http->post('/notifications', $dadosNotificacao);
53
    }
54
55
    // Deleta uma notificação
56
    public function delete($id){
57
        return $this->http->get('/notifications/'.$id,'','DELETE');
58
    }
59
60
}
61