SettingsService::getCustomNotifications()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 3
nop 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Service;
13
14
class SettingsService
15
{
16
    /**
17
     * Returns an array (key-value pair) of custom notifications that can be used in
18
     * select boxes
19
     */
20
    public function getCustomNotifications(array $settings): array
21
    {
22
        if (!isset($settings['notification']['customNotifications']) ||
23
            !is_array($settings['notification']['customNotifications'])
24
        ) {
25
            return [];
26
        }
27
        $notifications = [];
28
        foreach ($settings['notification']['customNotifications'] as $notificationKey => $notificationValue) {
29
            $notifications[$notificationKey] = $notificationValue['title'] ?? '';
30
        }
31
32
        return $notifications;
33
    }
34
}
35