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

LearningPathCompleted   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A generate() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\PluginBundle\XApi\ToolExperience\Statement;
8
9
use Chamilo\CourseBundle\Entity\CLp;
10
use Chamilo\CourseBundle\Entity\CLp as CLpEntity;
11
use Chamilo\CourseBundle\Entity\CLpView;
12
use Chamilo\CourseBundle\Entity\CLpView as CLpViewEntity;
13
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\LearningPath as LearningPathActivity;
14
use Chamilo\PluginBundle\XApi\ToolExperience\Actor\User as UserActor;
15
use Chamilo\PluginBundle\XApi\ToolExperience\Verb\Completed;
16
use Xabbuh\XApi\Model\Result;
17
use Xabbuh\XApi\Model\Score;
18
use Xabbuh\XApi\Model\Statement;
19
20
/**
21
 * Class LearningPathCompleted.
22
 */
23
class LearningPathCompleted extends BaseStatement
24
{
25
    /**
26
     * @var CLpView
27
     */
28
    private $lpView;
29
30
    /**
31
     * @var CLp
32
     */
33
    private $lp;
34
35
    public function __construct(CLpViewEntity $lpView, CLpEntity $lp)
36
    {
37
        $this->lpView = $lpView;
38
        $this->lp = $lp;
39
    }
40
41
    public function generate(): Statement
42
    {
43
        $user = api_get_user_entity($this->lpView->getUserId());
0 ignored issues
show
Bug introduced by
The method getUserId() does not exist on Chamilo\CourseBundle\Entity\CLpView. Did you maybe mean getUser()? ( Ignorable by Annotation )

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

43
        $user = api_get_user_entity($this->lpView->/** @scrutinizer ignore-call */ getUserId());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
        $userActor = new UserActor($user);
45
        $completedVerb = new Completed();
46
        $lpActivity = new LearningPathActivity($this->lp);
47
48
        return new Statement(
49
            $this->generateStatementId('learning-path'),
50
            $userActor->generate(),
51
            $completedVerb->generate(),
52
            $lpActivity->generate(),
53
            new Result(
54
                new Score(1, 100, 0, 100),
55
                null,
56
                true
57
            ),
58
            null,
59
            api_get_utc_datetime(null, false, true),
60
            null,
61
            $this->generateContext()
62
        );
63
    }
64
}
65