Passed
Push — master ( 7c4e47...1ba277 )
by
unknown
02:58
created

Breakingnews::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace One\Model;
4
5
use One\Collection;
6
7
class Breakingnews 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 $content
22
     * @param string $tag
23
     * @param bool $status
24
     * @param bool $isPushed
25
     * @param string $startDate
26
     * @param string $endDate
27
     * @param string $url
28
     * @param string $type
29
     * @param string $video
30
     * @param string $logo
31
     */
32
    public function __construct(
33
        string $uniqueId,
34
        string $title,
35
        string $content,
36
        string $tag,
37
        $status = false,
38
        $isPushed = false,
39
        string $startDate,
40
        string $endDate,
41
        $identifier = null,
42
        string $url = '',
43
        string $type = '',
44
        string $video = '',
45
        string $logo = ''
46
    ) {
47
        $properties = [
48
            'title' => $this->filterStringInstance($title),
49
            'content' => $this->filterStringInstance($content),
50
            'tag' => $this->filterStringInstance($tag),
51
            'status' => $status ? 1 : 0,
52
            'is_pushed' => $isPushed ? 1 : 0,
53
            'start_date' => $this->filterDateInstance($startDate),
54
            'end_date' => $this->filterDateInstance($endDate),
55
            'uniqueId' => $uniqueId
56
        ];
57
58
        $this->collection = new Collection($properties);
59
        
60
        if (!empty($this->filterStringInstance($url))) {
61
            $this->collection->offsetSet('url', $this->filterStringInstance($url));
62
        }
63
        if (!empty($this->filterStringInstance($type))) {
64
            $this->collection->offsetSet('type', $this->filterStringInstance($type));
65
        }
66
        if (!empty($this->filterStringInstance($video))) {
67
            $this->collection->offsetSet('video', $this->filterStringInstance($video));
68
        }
69
        if (!empty($this->filterStringInstance($logo))) {
70
            $this->collection->offsetSet('logo', $this->filterStringInstance($logo));
71
        }
72
73
        if ($identifier) {
74
            $this->setId((string) $identifier);
75
        }
76
    }
77
78
    /**
79
     * setIdentifier from rest api response
80
     */
81
    public function setId(string $identifier): void
82
    {
83
        $this->identifier = $identifier;
84
    }
85
86
    /**
87
     * getIdentifier set before
88
     */
89
    public function getId(): string
90
    {
91
        return $this->identifier;
92
    }
93
}
94
95