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

Course   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 18 2
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\PluginBundle\XApi\ToolExperience\Activity;
8
9
use Xabbuh\XApi\Model\Activity;
10
use Xabbuh\XApi\Model\Definition;
11
use Xabbuh\XApi\Model\IRI;
12
use Xabbuh\XApi\Model\LanguageMap;
13
14
/**
15
 * Class Course.
16
 */
17
class Course extends BaseActivity
18
{
19
    public function generate(): Activity
20
    {
21
        $course = api_get_course_entity();
22
        $session = api_get_session_entity();
23
24
        $languageIso = api_get_language_isocode($course->getCourseLanguage());
25
26
        $courseUrl = api_get_course_url(
27
            $course->getCode(),
28
            $session ? $session->getId() : 0
29
        );
30
31
        return new Activity(
32
            IRI::fromString($courseUrl),
33
            new Definition(
34
                LanguageMap::create([$languageIso => $course->getTitle()]),
35
                null,
36
                IRI::fromString('http://id.tincanapi.com/activitytype/lms/course')
37
            )
38
        );
39
    }
40
}
41