Completed
Push — master ( d0dba3...b098fd )
by Sergey
02:42
created

Endpoint   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getResourceUri() 0 5 2
A getResource() 0 4 1
1
<?php
2
3
namespace seregazhuk\HeadHunterApi\EndPoints;
4
5
use seregazhuk\HeadHunterApi\Contracts\RequestInterface;
6
7
abstract class Endpoint
8
{
9
    const RESOURCE = '/resource';
10
11
    /**
12
     * @var RequestInterface
13
     */
14
    protected $request;
15
16
    public function __construct(RequestInterface $request)
17
    {
18
        $this->request = $request;
19
    }
20
21
    /**
22
     * @param string $uri
23
     * @return string
24
     */
25
    protected function getResourceUri($uri = '')
26
    {
27
        $resource = static::RESOURCE;
28
        return empty($uri) ? $resource : $resource . sprintf('/%s', $uri);
29
    }
30
31
    /**
32
     * @param string $verb
33
     * @return array
34
     */
35
    protected function getResource($verb)
36
    {
37
        return $this->request->get($this->getResourceUri($verb));
38
    }
39
}