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

Portfolio   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 26 1
A __construct() 0 3 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