Completed
Push — master ( 29547f...5e0db9 )
by Matthew
02:17
created

UpdateTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
endpoint() 0 1 ?
A update() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Matthew
5
 * Date: 21/04/2016
6
 * Time: 9:10 AM
7
 */
8
9
namespace Freshdesk\Resources\Traits;
10
11
12
trait UpdateTrait
13
{
14
15
    /**
16
     * @param null $end string
17
     * @return string
18
     */
19
    abstract public function endpoint($end = null);
20
21
    /**
22
     *
23
     * Update a resource for the given $id with the supplied array.
24
     *
25
     * @param int $id
26
     * @param array $data
27
     * @return array|null
28
     * @throws \Freshdesk\Exceptions\AccessDeniedException
29
     * @throws \Freshdesk\Exceptions\ApiException
30
     * @throws \Freshdesk\Exceptions\AuthenticationException
31
     * @throws \Freshdesk\Exceptions\ConflictingStateException
32
     * @throws \Freshdesk\Exceptions\NotFoundException
33
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
34
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
35
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
36
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
37
     * @throws \Freshdesk\Exceptions\ValidationException
38
     */
39
    public function update($id, array $data)
40
    {
41
        return $this->api->request('PUT', $this->endpoint($id), $data);
0 ignored issues
show
Bug introduced by
The property api does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
42
    }
43
44
}