Passed
Pull Request — master (#74)
by Rustam
02:43
created

ProxyMethodCallEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 9
dl 0
loc 20
ccs 10
cts 10
cp 1
crap 1
rs 9.9666

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
namespace Yiisoft\Yii\Debug\Event;
6
7
final class ProxyMethodCallEvent
8
{
9
    public string $service;
10
11
    public string $class;
12
13
    public string $methodName;
14
15
    public ?array $arguments;
16
17
    public $result;
18
19
    public string $status;
20
21
    public ?object $error;
22
23
    public float $timeStart;
24
25
    public float $timeEnd;
26
27 4
    public function __construct(
28
        string $service,
29
        string $class,
30
        string $method,
31
        ?array $arguments,
32
        $result,
33
        string $status,
34
        ?object $error,
35
        float $timeStart,
36
        float $timeEnd
37
    ) {
38 4
        $this->service = $service;
39 4
        $this->class = $class;
40 4
        $this->methodName = $method;
41 4
        $this->arguments = $arguments;
42 4
        $this->result = $result;
43 4
        $this->status = $status;
44 4
        $this->error = $error;
45 4
        $this->timeStart = $timeStart;
46 4
        $this->timeEnd = $timeEnd;
47 4
    }
48
}
49