GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 21abfc...40d55e )
by Anton
02:41
created

RunParams::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 9
dl 0
loc 11
rs 10
c 1
b 0
f 0

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 Deployer\Ssh;
4
5
class RunParams
6
{
7
    public function __construct(
8
        public ?string  $shell = null,
9
        public ?string $cwd = null,
10
        public ?array  $env = null,
11
        public ?string $dotenv = null,
12
        public bool    $nothrow = false,
13
        public ?int    $timeout = null,
14
        public ?int    $idleTimeout = null,
15
        public bool    $forceOutput = false,
16
        public ?array  $secrets = null,
17
    ) {}
18
19
    public function with(
20
        ?array $secrets = null,
21
        ?int $timeout = null,
22
    ): self {
23
        $params = clone $this;
24
        $params->secrets = array_merge($params->secrets ?? [], $secrets ?? []);
25
        $params->timeout = $timeout ?? $params->timeout;
26
        return $params;
27
    }
28
}
29