Passed
Pull Request — 1.11.x (#4368)
by Angel Fernando Quiroz
08:39 queued 22s
created

PortfolioItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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