Completed
Push — master ( 481c33...0c5dca )
by Nate
04:03
created

AbstractMiddleware   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 41
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
getPath() 0 1 ?
assemblePath() 0 1 ?
A prepareUri() 0 11 1
1
<?php
2
3
namespace Flipbox\Relay\HubSpot\Middleware;
4
5
use Psr\Http\Message\RequestInterface;
6
7
abstract class AbstractMiddleware extends \Flipbox\Relay\Middleware\AbstractMiddleware
8
{
9
    /**
10
     * The URI Host
11
     */
12
    const HOST = 'api.hubapi.com';
13
14
    /**
15
     * The URI Scheme
16
     */
17
    const SCHEME = 'https';
18
19
    /**
20
     * The API endpoint path, after the version
21
     *
22
     * @return string
23
     */
24
    abstract protected function getPath(): string;
25
26
    /**
27
     * @param string $path
28
     * @return string
29
     */
30
    abstract protected function assemblePath(string $path): string;
31
32
    /**
33
     * @param RequestInterface $request
34
     * @return RequestInterface
35
     */
36
    protected function prepareUri(RequestInterface $request)
37
    {
38
        return $request->withUri(
39
            $request->getUri()
40
                ->withHost(static::HOST)
41
                ->withScheme(static::SCHEME)
42
                ->withPath(
43
                    $this->assemblePath($this->getPath())
44
                )
45
        );
46
    }
47
}
48