Completed
Push — develop ( 3dabae...af53e6 )
by Nate
02:32
created

Remove   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 64
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A addPayload() 0 8 2
A addUri() 0 10 2
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/relay-hubspot/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/relay-hubspot
7
 */
8
9
namespace Flipbox\Relay\HubSpot\Builder\Resources\ContactList\Contacts;
10
11
use Flipbox\Relay\HubSpot\AuthorizationInterface;
12
use Flipbox\Relay\HubSpot\Builder\HttpRelayBuilder;
13
use Flipbox\Relay\HubSpot\Middleware\JsonRequest as JsonMiddleware;
14
use Flipbox\Relay\HubSpot\Middleware\ResourceV1;
15
use Psr\Log\LoggerInterface;
16
use Psr\SimpleCache\CacheInterface;
17
18
/**
19
 * @author Flipbox Factory <[email protected]>
20
 * @since 1.0.0
21
 */
22
class Remove extends HttpRelayBuilder
23
{
24
    /**
25
     * The node
26
     */
27
    const NODE = 'contacts';
28
29
    /**
30
     * The resource
31
     */
32
    const RESOURCE = 'lists';
33
34
    /**
35
     * @param string $id
36
     * @param array $payload
37
     * @param AuthorizationInterface $authorization
38
     * @param CacheInterface $cache
39
     * @param LoggerInterface|null $logger
40
     * @param array $config
41
     */
42
    public function __construct(
43
        string $id,
44
        array $payload,
45
        AuthorizationInterface $authorization,
46
        CacheInterface $cache,
0 ignored issues
show
Unused Code introduced by
The parameter $cache is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
        LoggerInterface $logger = null,
48
        $config = []
49
    ) {
50
        parent::__construct($authorization, $logger, $config);
51
52
        $this->addUri($id, $logger)
53
            ->addPayload($payload, $logger);
54
    }
55
56
    /**
57
     * @param array $payload
58
     * @param LoggerInterface|null $logger
59
     * @return $this
60
     */
61
    protected function addPayload(array $payload, LoggerInterface $logger = null)
62
    {
63
        return $this->addAfter('body', [
64
            'class' => JsonMiddleware::class,
65
            'payload' => $payload,
66
            'logger' => $logger ?: $this->getLogger()
67
        ], 'uri');
68
    }
69
70
    /**
71
     * @param string $id
72
     * @param LoggerInterface|null $logger
73
     * @return $this
74
     */
75
    protected function addUri(string $id, LoggerInterface $logger = null)
76
    {
77
        return $this->addBefore('uri', [
78
            'class' => ResourceV1::class,
79
            'method' => 'POST',
80
            'node' => self::NODE,
81
            'resource' => self::RESOURCE . '/' . $id . '/remove',
82
            'logger' => $logger ?: $this->getLogger()
83
        ]);
84
    }
85
}
86