Completed
Push — master ( 0a266f...c03660 )
by Pascal
02:42
created

Endpoint::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php namespace Atog\Api;
2
3
/**
4
 * Abstract Class Endpoint
5
 * @package Atog\Api
6
 */
7
abstract class Endpoint
8
{
9
    /**
10
     * @var \Atog\Api\Client
11
     */
12
    protected $client;
13
    
14
    /**
15
     * @var \Atog\Api\Model
16
     */
17
    protected $model;
18
    
19
    /**
20
     * @var string
21
     */
22
    protected $endpoint;
23
    
24
    /**
25
     * Endpoint constructor.
26
     * @param \Atog\Api\Client $client
27
     * @param \Atog\Api\Model  $model
28
     */
29 2
    public function __construct(Client $client, Model $model)
30
    {
31 2
        $this->client = $client;
32 2
        $this->model = $model;
33 2
    }
34
35
    /**
36
     * @return \Atog\Api\Model
37
     */
38 1
    public function getModel()
39
    {
40 1
        return $this->model;
41
    }
42
    
43
    /**
44
     * Get the endpoint url for the request
45
     * @param string $path
46
     * @param bool   $withTrailingSlash
47
     * @return string
48
     */
49 1
    public function getEndpointUrl($path, $withTrailingSlash)
50
    {
51 1
        $url = $this->endpoint . '/' . $path;
52
        
53 1
        if ($withTrailingSlash) {
54 1
            $url = $url . '/';
55 1
        }
56
        
57 1
        return $url;
58
    }
59
}
60