| Total Complexity | 3 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 93.33% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 18 | class SubscriberAddHandler extends AbstractHandler |
||
| 19 | { |
||
| 20 | const API_ENDPOINT = '/rest/subscriber/add'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $email |
||
| 24 | * @param string $listHash |
||
| 25 | * @param int $subscriberStatus |
||
| 26 | * @param bool $sendConfirmationToSubscriber |
||
| 27 | * @param array $customFieldsWithValues |
||
| 28 | * @return null |
||
| 29 | */ |
||
| 30 | 42 | public function addSubscriber( |
|
| 31 | string $email, |
||
| 32 | string $listHash, |
||
| 33 | int $subscriberStatus = 0, |
||
| 34 | bool $sendConfirmationToSubscriber = false, |
||
| 35 | array $customFieldsWithValues = [] |
||
| 36 | ) { |
||
| 37 | 42 | $getParameters = []; |
|
| 38 | 12 | $postParameters = [ |
|
| 39 | 42 | 'email' => $email, |
|
| 40 | 42 | 'list' => $listHash, |
|
| 41 | 42 | 'state' => $subscriberStatus, |
|
| 42 | 42 | 'confirm' => $sendConfirmationToSubscriber, |
|
| 43 | 'custom_fields' => $customFieldsWithValues ?: null |
||
| 44 | ]; |
||
| 45 | |||
| 46 | 30 | $postParameters = array_filter($postParameters, function ($value) { |
|
| 47 | 42 | return $value !== null; |
|
| 48 | 42 | }); |
|
| 49 | 42 | $this->processRequest($getParameters, $postParameters); |
|
| 50 | 7 | return null; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return string |
||
| 55 | */ |
||
| 56 | 7 | protected function getApiEndpoint(): string |
|
| 59 | } |
||
| 60 | } |
||
| 61 |