Headline   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 13
c 1
b 0
f 1
dl 0
loc 55
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 3
A getId() 0 3 1
A setId() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace One\Model;
4
5
use One\Collection;
6
7
class Headline extends Model
8
{
9
    /**
10
     * identifier
11
     *
12
     * @var string
13
     */
14
    protected $identifier = null;
15
16
    /**
17
     * constuctor
18
     *
19
     * @param string $uniqueId
20
     * @param string $title
21
     * @param string $text
22
     * @param string $url
23
     * @param bool $active
24
     */
25
    public function __construct(
26
        string $uniqueId,
27
        string $title,
28
        string $content,
29
        string $url,
30
        $active = false,
31
        $identifier = null
32
    ) {
33
        $properties = [
34
            'title' => $this->filterStringInstance($title),
35
            'content' => $this->filterStringInstance($content),
36
            'url' => $this->filterUriInstance($url),
37
            'show' => $active ? 1 : 0,
38
            'uniqueId' => $uniqueId
39
        ];
40
41
        $this->collection = new Collection($properties);
42
43
        if ($identifier) {
44
            $this->setId((string) $identifier);
45
        }
46
    }
47
48
    /**
49
     * setIdentifier from rest api response
50
     */
51
    public function setId(string $identifier): void
52
    {
53
        $this->identifier = $identifier;
54
    }
55
56
    /**
57
     * getIdentifier set before
58
     */
59
    public function getId(): string
60
    {
61
        return $this->identifier;
62
    }
63
}
64
65