Passed
Pull Request — master (#6127)
by Angel Fernando Quiroz
08:01
created

MyStudentsLpTrackingEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addContent() 0 13 1
A addHeader() 0 13 1
A getHeaders() 0 3 1
A getStudentId() 0 3 1
A getContents() 0 3 1
A getLpId() 0 3 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
declare(strict_types=1);
6
7
namespace Chamilo\CoreBundle\Event;
8
9
class MyStudentsLpTrackingEvent extends AbstractEvent
10
{
11
    public function getHeaders(): array
12
    {
13
        return $this->data['headers'] ?? [];
14
    }
15
16
    public function addHeader(string $title, array $attrs): static
17
    {
18
        $headers = $this->getHeaders();
19
20
        $this->data['headers'] = [
21
            ...$headers,
22
            [
23
                'title' => $title,
24
                'attrs' => $attrs,
25
            ],
26
        ];
27
28
        return $this;
29
    }
30
31
    public function getContents(): array
32
    {
33
        return $this->data['contents'] ?? [];
34
    }
35
36
    public function addContent(string $value, array $attrs): static
37
    {
38
        $contents = $this->getContents();
39
40
        $this->data['contents'] = [
41
            ...$contents,
42
            [
43
                'value' => $value,
44
                'attrs' => $attrs,
45
            ],
46
        ];
47
48
        return $this;
49
    }
50
51
    public function getLpId(): ?int
52
    {
53
        return $this->data['lp_id'] ?? null;
54
    }
55
56
    public function getStudentId(): ?int
57
    {
58
        return $this->data['student_id'] ?? null;
59
    }
60
}
61