Passed
Pull Request — master (#5629)
by Angel Fernando Quiroz
08:49
created

XApiCreateCourseHookObserver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 21
c 1
b 0
f 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A hookCreateCourse() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
class XApiCreateCourseHookObserver extends HookObserver implements HookCreateCourseObserverInterface
8
{
9
    protected function __construct()
10
    {
11
        parent::__construct(
12
            'plugin/xapi/src/XApiPlugin.php',
13
            'xapi'
14
        );
15
    }
16
17
    public function hookCreateCourse(HookCreateCourseEventInterface $hook): void
18
    {
19
        $data = $hook->getEventData();
20
21
        $type = $data['type'];
22
        $courseInfo = $data['course_info'];
23
24
        $plugin = XApiPlugin::create();
25
26
        if (HOOK_EVENT_TYPE_POST == $type) {
27
            $plugin->addCourseToolForTinCan($courseInfo['real_id']);
28
        }
29
    }
30
}
31