AudioEpisode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 35
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 35
rs 9.7333
cc 1
nc 1
nop 15

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
2
3
namespace PODEntender\Domain\Model\Post;
4
5
use DateTimeInterface;
6
7
class AudioEpisode extends Post
8
{
9
    private $explicit;
10
11
    private $duration;
12
13
    private $audioUrl;
14
15
    private $audioCover;
16
17
    public function __construct(
18
        string $guid,
19
        string $url,
20
        string $title,
21
        string $description,
22
        string $author,
23
        string $content,
24
        string $category,
25
        PostImageCollection $images,
26
        array $tags,
27
        DateTimeInterface $createdAt,
28
        DateTimeInterface $updatedAt,
29
        string $explicit,
30
        string $duration,
31
        string $audioUrl,
32
        string $audioCover
33
    ) {
34
        parent::__construct(
35
            $guid,
36
            $url,
37
            $title,
38
            $description,
39
            $author,
40
            $content,
41
            $category,
42
            $images,
43
            $tags,
44
            $createdAt,
45
            $updatedAt
46
        );
47
48
        $this->explicit = $explicit;
49
        $this->duration = $duration;
50
        $this->audioUrl = $audioUrl;
51
        $this->audioCover = $audioCover;
52
    }
53
54
    public function explicit(): string
55
    {
56
        return $this->explicit;
57
    }
58
59
    public function duration(): string
60
    {
61
        return $this->duration;
62
    }
63
64
    public function audioUrl(): string
65
    {
66
        return $this->audioUrl;
67
    }
68
69
    public function audioCover(): string
70
    {
71
        return $this->audioCover;
72
    }
73
}
74