Passed
Pull Request — 1.11.x (#4501)
by Angel Fernando Quiroz
09:49
created

Portfolio   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 26 1
A __construct() 0 3 1
1
<?php
2
3
namespace Chamilo\PluginBundle\XApi\ToolExperience\Activity;
4
5
use Chamilo\UserBundle\Entity\User;
6
use Xabbuh\XApi\Model\Activity;
7
use Xabbuh\XApi\Model\Definition;
8
use Xabbuh\XApi\Model\IRI;
9
use Xabbuh\XApi\Model\LanguageMap;
10
11
class Portfolio extends BaseActivity
12
{
13
    /** @var User */
14
    private $owner;
15
16
    public function __construct(User $owner)
17
    {
18
        $this->owner = $owner;
19
    }
20
21
    public function generate(): Activity
22
    {
23
        $langIso = api_get_language_isocode();
24
25
        $iri = $this->generateIri(
26
            WEB_CODE_PATH,
27
            'portfolio/index.php',
28
            [
29
                'action' => 'list',
30
                'user' => $this->owner->getId(),
31
            ]
32
        );
33
34
        return new Activity(
35
            IRI::fromString($iri),
36
            new Definition(
37
                LanguageMap::create(
38
                    [
39
                        $langIso => sprintf(
40
                            get_lang('XUserPortfolioItems'),
41
                            $this->owner->getCompleteNameWithUsername()
42
                        ),
43
                    ]
44
                ),
45
                null,
46
                IRI::fromString('http://id.tincanapi.com/activitytype/collection-simple')
47
            )
48
        );
49
    }
50
}
51