Livestreaming::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 12
c 1
b 0
f 1
nc 4
nop 9
dl 0
loc 26
rs 9.8666

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php declare(strict_types=1);
2
3
namespace One\Model;
4
5
use One\Collection;
6
7
class Livestreaming 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 $desc
22
     * @param string $urlLive
23
     * @param string $urlThumbnail
24
     * @param \DateTimeInterface|string $publishedAt
25
     * @param \DateTimeInterface|string $endAt
26
     * @param bool $publishStatus
27
     
28
     */
29
30
    public function __construct(
31
        string $uniqueId,
32
        string $title,
33
        string $desc,
34
        string $urlLive,
35
        string $urlThumbnail,
36
        $publishedAt = null,
37
        $endAt = null,
38
        $publishStatus = false,
39
        $identifier = null
40
    ) {
41
        $properties = [
42
            'title' => $this->filterStringInstance($title),
43
            'desc' => $this->filterStringInstance($desc),
44
            'url_live' => $this->filterStringInstance($urlLive),
45
            'url_thumbnail' => $this->filterStringInstance($urlThumbnail),
46
            'published_at' => $this->filterDateInstance($publishedAt),
47
            'end_at' => $this->filterDateInstance($endAt),
48
            'publish_status' => $publishStatus ? 1 : 0,
49
            'uniqueId' => $uniqueId
50
        ];
51
52
        $this->collection = new Collection($properties);
53
54
        if ($identifier) {
55
            $this->setId((string) $identifier);
56
        }
57
    }
58
59
    /**
60
     * setIdentifier from rest api response
61
     */
62
    public function setId(string $identifier): void
63
    {
64
        $this->identifier = $identifier;
65
    }
66
67
    /**
68
     * getIdentifier set before
69
     */
70
    public function getId(): string
71
    {
72
        return $this->identifier;
73
    }
74
}
75
76