ViewTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
endpoint() 0 1 ?
api() 0 1 ?
A view() 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
 * View Trait
13
 *
14
 * @package Freshdesk\Resources\Traits
15
 *
16
 */
17
trait ViewTrait
18
{
19
    /**
20
     * @param integer $end string
21
     * @return string
22
     * @internal
23
     */
24
    abstract protected function endpoint($end = null);
25
26
    /**
27
     * @return \Freshdesk\Api
28
     * @internal
29
     */
30
    abstract protected function api();
31
32
    /**
33
     * View a resource
34
     *
35
     * Use 'include' to embed additional details in the response. Each include will consume an additional credit.
36
     * For example if you embed the requester and company information you will be charged a total of 3 API credits for the call.
37
     * See Freshdesk's documentation for details.
38
     *
39
     * @api
40
     * @param int $id The resource id
41
     * @param array|null $query
42
     * @return array|null
43
     * @throws \Freshdesk\Exceptions\AccessDeniedException
44
     * @throws \Freshdesk\Exceptions\ApiException
45
     * @throws \Freshdesk\Exceptions\AuthenticationException
46
     * @throws \Freshdesk\Exceptions\ConflictingStateException
47
     * @throws \Freshdesk\Exceptions\NotFoundException
48
     * @throws \Freshdesk\Exceptions\RateLimitExceededException
49
     * @throws \Freshdesk\Exceptions\UnsupportedContentTypeException
50
     * @throws \Freshdesk\Exceptions\MethodNotAllowedException
51
     * @throws \Freshdesk\Exceptions\UnsupportedAcceptHeaderException
52
     * @throws \Freshdesk\Exceptions\ValidationException
53
     */
54
    public function view($id, array $query = null)
55
    {
56
        return $this->api()->request('GET', $this->endpoint($id), null, $query);
57
    }
58
}
59