Completed
Push — master ( 8e286a...78e0f9 )
by Rafał
09:27
created

FailedEntry::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 8

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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Core Bundle.
7
 *
8
 * Copyright 2020 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2020 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\CoreBundle\Model;
18
19
use DateTimeInterface;
20
21
class FailedEntry
22
{
23
    /** @var int */
24
    private $id;
25
26
    /** @var string */
27
    private $class;
28
29
    /** @var DateTimeInterface|null */
30
    private $failedAt;
31
32
    /** @var string|null */
33
    private $errorMessage;
34
35
    /** @var string */
36
    private $transport;
37
38
    /** @var array */
39
    private $redeliveries = [];
40
41
    /** @var array */
42
    private $message;
43
44
    /** @var string|null */
45
    private $exceptionStacktrace;
46
47
    public function __construct(
48
        int $id,
49
        string $class,
50
        ?DateTimeInterface $failedAt,
51
        ?string $errorMessage,
52
        string $transport,
53
        array $redeliveries = [],
54
        array $message,
55
        ?string $exceptionStacktrace
56
    ) {
57
        $this->id = $id;
58
        $this->class = $class;
59
        $this->failedAt = $failedAt;
60
        $this->errorMessage = $errorMessage;
61
        $this->transport = $transport;
62
        $this->redeliveries = $redeliveries;
63
        $this->message = $message;
64
        $this->exceptionStacktrace = $exceptionStacktrace;
65
    }
66
67
    public function getId(): int
68
    {
69
        return $this->id;
70
    }
71
72
    public function getClass(): string
73
    {
74
        return $this->class;
75
    }
76
77
    public function getFailedAt(): ?DateTimeInterface
78
    {
79
        return $this->failedAt;
80
    }
81
82
    public function getErrorMessage(): ?string
83
    {
84
        return $this->errorMessage;
85
    }
86
87
    public function getTransport(): string
88
    {
89
        return $this->transport;
90
    }
91
92
    public function getRedeliveries(): array
93
    {
94
        return $this->redeliveries;
95
    }
96
97
    public function getMessage(): array
98
    {
99
        return $this->message;
100
    }
101
102
    public function getExceptionStacktrace(): ?string
103
    {
104
        return $this->exceptionStacktrace;
105
    }
106
}
107