Passed
Pull Request — master (#5629)
by Angel Fernando Quiroz
10:06 queued 01:32
created

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