PhoneNumbers   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
1
<?php
2
namespace GeoPhone\Endpoints\v1;
3
4
use GeoPhone\Models\GeoPhone;
5
use LunixREST\Server\APIRequest\APIRequest;
6
use LunixREST\Server\APIResponse\APIResponseData;
7
use LunixREST\Server\Router\Endpoint\DefaultEndpoint;
8
use LunixREST\Server\Router\Endpoint\Exceptions\ElementNotFoundException;
9
use LunixREST\Server\Router\Endpoint\Exceptions\EndpointExecutionException;
10
use LunixREST\Server\Router\Endpoint\Exceptions\InvalidRequestException;
11
use LunixREST\Server\Router\Endpoint\Exceptions\UnsupportedMethodException;
12
13
class PhoneNumbers extends DefaultEndpoint
14
{
15
16
    protected $geoPhone;
17
18
    /**
19
     * PhoneNumbers constructor.
20
     * @param GeoPhone $geoPhone
21
     */
22
    public function __construct(GeoPhone $geoPhone)
23
    {
24
        $this->geoPhone = $geoPhone;
25
    }
26
27
    /**
28
     * @param APIRequest $request
29
     * @return APIResponseData
30
     * @throws EndpointExecutionException
31
     * @throws UnsupportedMethodException
32
     * @throws ElementNotFoundException
33
     * @throws InvalidRequestException
34
     */
35
    public function get(APIRequest $request): APIResponseData
36
    {
37
        return $this->geoPhone->lookupNumber($request->getElement())->getAsResponseData();
38
    }
39
}
40