Passed
Push — hypernext ( d18b5c...96a12c )
by Nico
12:00
created

EntityParams::getTags()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * @author Nicolas CARPi <[email protected]>
4
 * @copyright 2012 Nicolas CARPi
5
 * @see https://www.elabftw.net Official website
6
 * @license AGPL-3.0
7
 * @package elabftw
8
 */
9
declare(strict_types=1);
10
11
namespace Elabftw\Elabftw;
12
13
use Elabftw\Interfaces\EntityParamsInterface;
14
use Elabftw\Services\Filter;
15
16
class EntityParams extends ContentParams implements EntityParamsInterface
17
{
18
    public function __construct(string $content, string $target = '', protected ?array $extra = null)
19
    {
20
        parent::__construct($content, $target);
21
    }
22
23
    public function getTitle(): string
24
    {
25
        return Filter::title($this->content);
26
    }
27
28
    public function getTags(): array
29
    {
30
        return $this->extra['tags'] ?? array();
31
    }
32
33
    public function getDate(): string
34
    {
35
        return Filter::kdate($this->content);
36
    }
37
38
    public function getBody(): string
39
    {
40
        return Filter::body($this->content);
41
    }
42
43
    public function getExtraBody(): string
44
    {
45
        return Filter::body($this->extra['body'] ?? '');
46
    }
47
48
    public function getRating(): int
49
    {
50
        return (int) $this->content;
51
    }
52
53
    public function getMetadata(): string
54
    {
55
        return $this->content;
56
    }
57
58
    public function getField(): string
59
    {
60
        return Filter::sanitize($this->extra['jsonField'] ?? '');
61
    }
62
63
    public function getUserId(): int
64
    {
65
        return (int) $this->content;
66
    }
67
}
68