PhoneNumbers::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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