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

CreateTrait::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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 CreateTrait
13
{
14
15
    /**
16
     * @param null $end string
17
     * @return string
18
     */
19
    abstract public function endpoint($end = null);
20
21
    /**
22
     *
23
     * Creates a resource with the supplied data.
24
     *
25
     * @param array $data
26
     * @return array|null
27
     * @throws \Freshdesk\Exceptions\AccessDeniedException
28
     * @throws \Freshdesk\Exceptions\ApiException
29
     * @throws \Freshdesk\Exceptions\AuthenticationException
30
     * @throws \Freshdesk\Exceptions\ConflictingStateException
31
     * @throws \Freshdesk\Exceptions\NotFoundException
32
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
33
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
34
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
35
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
36
     * @throws \Freshdesk\Exceptions\ValidationException
37
     */
38
    public function create(array $data)
39
    {
40
        $this->api->request('POST', $this->endpoint(), $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...
41
    }
42
}