Passed
Pull Request — 1.11.x (#4368)
by Angel Fernando Quiroz
08:12
created

PortfolioItem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generateContext() 0 20 2
A __construct() 0 3 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\XApi\ToolExperience\Statement;
6
7
use Chamilo\CoreBundle\Entity\Portfolio;
8
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\PortfolioCategory;
9
use Xabbuh\XApi\Model\Context;
10
11
abstract class PortfolioItem extends BaseStatement
12
{
13
    protected $item;
14
15
    public function __construct(Portfolio $item)
16
    {
17
        $this->item = $item;
18
    }
19
20
    protected function generateContext(): Context
21
    {
22
        $context = parent::generateContext();
23
24
        $category = $this->item->getCategory();
25
26
        if ($category) {
0 ignored issues
show
introduced by
$category is of type Chamilo\CoreBundle\Entity\PortfolioCategory, thus it always evaluated to true.
Loading history...
27
            $categoryActivity = new PortfolioCategory($category);
28
29
            $contextActivities = $context
30
                ->getContextActivities()
31
                ->withAddedCategoryActivity(
32
                    $categoryActivity->generate()
33
                )
34
            ;
35
36
            $context = $context->withContextActivities($contextActivities);
37
        }
38
39
        return $context;
40
    }
41
}
42