CreateTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
endpoint() 0 1 ?
api() 0 1 ?
A create() 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
/**
13
 * Create Trait
14
 *
15
 * @package Freshdesk\Resources\Traits
16
 */
17
trait CreateTrait
18
{
19
20
    /**
21
     * @param null $end string
22
     * @return string
23
     * @internal
24
     */
25
    abstract protected function endpoint($end = null);
26
27
    /**
28
     * @return \Freshdesk\Api
29
     * @internal
30
     */
31
    abstract protected function api();
32
33
    /**
34
     * Create a resource
35
     *
36
     * Create a resource with the supplied data
37
     *
38
     * @api
39
     * @param array $data The data
40
     * @return array|null
41
     * @throws \Freshdesk\Exceptions\AccessDeniedException
42
     * @throws \Freshdesk\Exceptions\ApiException
43
     * @throws \Freshdesk\Exceptions\AuthenticationException
44
     * @throws \Freshdesk\Exceptions\ConflictingStateException
45
     * @throws \Freshdesk\Exceptions\NotFoundException
46
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
47
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
48
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
49
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
50
     * @throws \Freshdesk\Exceptions\ValidationException
51
     */
52
    public function create(array $data)
53
    {
54
        return $this->api()->request('POST', $this->endpoint(), $data);
55
    }
56
}
57