AbstractResource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A endpoint() 0 4 2
A api() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Matthew
5
 * Date: 21/04/2016
6
 * Time: 8:20 AM
7
 */
8
9
namespace Freshdesk\Resources;
10
11
use Freshdesk\Api;
12
13
/**
14
 * Abstract Resource
15
 *
16
 * Abstract class which all resources inherit from
17
 *
18
 * @internal
19
 * @package Api\Resources
20
 */
21
abstract class AbstractResource
22
{
23
24
    /**
25
     * @var Api
26
     * @internal
27
     */
28
    private $api;
29
30
    /**
31
     * @var String
32
     * @internal
33
     */
34
    protected $endpoint;
35
36
    /**
37
     * Resource constructor
38
     *
39
     * Constructs a new resource
40
     *
41
     * @param Api $api
42
     * @internal
43
     *
44
     */
45
    public function __construct(Api $api)
46
    {
47
        $this->api = $api;
48
    }
49
50
    /**
51
     * Creates the endpoint
52
     *
53
     * @param null $id The endpoint terminator
54
     * @return string
55
     * @internal
56
     *
57
     */
58
    protected function endpoint($id = null)
59
    {
60
        return $id === null ? $this->endpoint : $this->endpoint . '/' . $id;
61
    }
62
63
    /**
64
     * @return Api
65
     * @internal
66
     */
67
    protected function api()
68
    {
69
        return $this->api;
70
    }
71
}
72