extcal_notify_iteminfo()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 19
rs 9.9
c 0
b 0
f 0
cc 4
nc 3
nop 2
1
<?php
2
3
use XoopsModules\Extcal\{Helper,
4
    EventHandler
5
};
6
7
/**
8
 * @param $category
9
 * @param $itemId
10
 *
11
 * @return mixed
12
 */
13
function extcal_notify_iteminfo($category, $itemId)
14
{
15
    if ('global' === $category || 'cat' === $category) {
16
        $item['name'] = '';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$item was never initialized. Although not strictly required by PHP, it is generally a good practice to add $item = array(); before regardless.
Loading history...
17
        $item['url']  = '';
18
19
        return $item;
20
    }
21
22
    if ('event' === $category) {
23
        $eventHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT);
24
        $event        = $eventHandler->getEvent($itemId, 0, true);
0 ignored issues
show
Bug introduced by
The method getEvent() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        /** @scrutinizer ignore-call */ 
25
        $event        = $eventHandler->getEvent($itemId, 0, true);
Loading history...
25
        $item['name'] = $event->getVar('event_title');
26
        $item['url']  = XOOPS_URL . '/modules/extcal/event.php?event=' . $event->getVar('event_id');
27
28
        return $item;
29
    }
30
31
    return '';
32
}
33