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

Portfolio::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

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