CampaignSendHandler::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: CampaignSendHandler.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 CampaignSendHandler
15
 *
16
 * @package MSlwk\FreshMail\Handler\Campaign
17
 */
18
class CampaignSendHandler extends AbstractHandler
19
{
20
    const API_ENDPOINT = '/rest/campaigns/send';
21
22
    /**
23
     * @param string $campaignHash
24
     * @param string $timeToSend
25
     * @return null
26
     */
27 49
    public function sendCampaign(string $campaignHash, string $timeToSend = '')
28
    {
29 49
        $getParameters = [];
30 14
        $postParameters = [
31 49
            'hash' => $campaignHash,
32
            'time' => $timeToSend ?: null
33
        ];
34
35 35
        $postParameters = array_filter($postParameters, function ($value) {
36 49
            return $value !== null;
37 49
        });
38 49
        $this->processRequest($getParameters, $postParameters);
39 7
        return null;
40
    }
41
42
    /**
43
     * @return string
44
     */
45 7
    protected function getApiEndpoint(): string
46
    {
47 7
        return self::API_ENDPOINT;
48
    }
49
}
50