ListEditHandler::getApiEndpoint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * File: ListEditHandler.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\FreshMail\Handler\Lists;
10
11
use MSlwk\FreshMail\Handler\AbstractHandler;
12
13
/**
14
 * Class ListEditHandler
15
 *
16
 * @package MSlwk\FreshMail\Handler\Lists
17
 */
18
class ListEditHandler extends AbstractHandler
19
{
20
    const API_ENDPOINT = '/rest/subscribers_list/update';
21
22
    /**
23
     * @param string $listHash
24
     * @param string $listName
25
     * @param string $description
26
     * @return null
27
     */
28 21
    public function updateSubscriberList(string $listHash, string $listName, string $description = '')
29
    {
30 21
        $getParameters = [];
31 6
        $postParameters = [
32 21
            'hash' => $listHash,
33 21
            'name' => $listName,
34
            'description' => $description ?: null
35
        ];
36
37 15
        $postParameters = array_filter($postParameters, function ($value) {
38 21
            return $value !== null;
39 21
        });
40 21
        $this->processRequest($getParameters, $postParameters);
41 7
        return null;
42
    }
43
44
    /**
45
     * @return string
46
     */
47 7
    protected function getApiEndpoint(): string
48
    {
49 7
        return self::API_ENDPOINT;
50
    }
51
}
52