Passed
Pull Request — master (#6127)
by Angel Fernando Quiroz
09:20
created

MyStudentsQuizTrackingEvent::getHeaders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 MyStudentsQuizTrackingEvent 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 getExerciseId(): ?int
52
    {
53
        return $this->data['exercise_id'] ?? null;
54
    }
55
56
    public function getStudentId(): ?int
57
    {
58
        return $this->data['student_id'] ?? null;
59
    }
60
}
61