CampaignEditHandler::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: CampaignEditHandler.php
4
 *
5
 * @author      Maciej Sławik <[email protected]>
6
 * Github:      https://github.com/maciejslawik
7
 */
8
9
namespace MSlwk\FreshMail\Handler\Campaign;
10
11
use MSlwk\FreshMail\Handler\AbstractHandler;
12
13
/**
14
 * Class CampaignEditHandler
15
 *
16
 * @package MSlwk\FreshMail\Handler\Campaign
17
 */
18
class CampaignEditHandler extends AbstractHandler
19
{
20
    const API_ENDPOINT = '/rest/campaigns/edit';
21
22
    /**
23
     * @param string $campaignHash
24
     * @param string $name
25
     * @param string $urlToDownloadContent
26
     * @param string $content
27
     * @param string $subject
28
     * @param string $fromAddress
29
     * @param string $fromName
30
     * @param string $replyTo
31
     * @param string $listHash
32
     * @param string $groupHash
33
     * @param string $resignLink
34
     * @return null
35
     */
36 21
    public function editCampaign(
37
        string $campaignHash,
38
        string $name = '',
39
        string $urlToDownloadContent = '',
40
        string $content = '',
41
        string $subject = '',
42
        string $fromAddress = '',
43
        string $fromName = '',
44
        string $replyTo = '',
45
        string $listHash = '',
46
        string $groupHash = '',
47
        string $resignLink = ''
48
    ) {
49 21
        $getParameters = [];
50 6
        $postParameters = [
51 21
            'id_hash' => $campaignHash,
52
            'name' => $name ?: null,
53
            'url' => $urlToDownloadContent ?: null,
54
            'html' => $content ?: null,
55
            'subject' => $subject ?: null,
56
            'from_address' => $fromAddress ?: null,
57
            'from_name' => $fromName ?: null,
58
            'reply_to' => $replyTo ?: null,
59
            'list' => $listHash ?: null,
60
            'group' => $groupHash ?: null,
61
            'resignlink' => $resignLink ?: null
62
        ];
63
64 15
        $postParameters = array_filter($postParameters, function ($value) {
65 21
            return $value !== null;
66 21
        });
67 21
        $this->processRequest($getParameters, $postParameters);
68 7
        return null;
69
    }
70
71
    /**
72
     * @return string
73
     */
74 7
    protected function getApiEndpoint(): string
75
    {
76 7
        return self::API_ENDPOINT;
77
    }
78
}
79