Passed
Push — main ( 455629...6ce649 )
by Vasil
14:18 queued 18s
created

Office::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 61
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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

How to fix   Long Method    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 VasilDakov\Econt\Model;
6
7
use JMS\Serializer\Annotation as Serializer;
8
9
readonly class Office
10
{
11 2
    public function __construct(
12
        #[Serializer\Type('int')]
13
        public ?int $id = null,
14
15
        #[Serializer\Type('string')]
16
        public ?string $code = null,
17
18
        #[Serializer\Type('string')]
19
        public ?string $name = null,
20
21
        #[Serializer\Type('string')]
22
        public ?string $nameEn = null,
23
24
        #[Serializer\Type('bool')]
25
        public ?bool $isMPS = null,
26
27
        #[Serializer\Type('bool')]
28
        public ?bool $isAPS = null,
29
30
        #[Serializer\Type('array')]
31
        public ?array $phones = null,
32
33
        #[Serializer\Type('array')]
34
        public ?array $emails = null,
35
36
        #[Serializer\Type(Address::class)]
37
        public ?Address $address = null,
0 ignored issues
show
Bug introduced by
The type VasilDakov\Econt\Model\Address was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
38
39
        #[Serializer\Type('string')]
40
        public ?string $info = null,
41
42
        #[Serializer\Type('string')]
43
        public ?string $currency = null,
44
45
        #[Serializer\Type('string')]
46
        public ?string $language = null,
47
48
        #[Serializer\Type('int')]
49
        public ?int $normalBusinessHoursFrom = null,
50
51
        #[Serializer\Type('int')]
52
        public ?int $normalBusinessHoursTo = null,
53
54
        #[Serializer\Type('array')]
55
        public ?array $shipmentTypes = null,
56
57
        #[Serializer\Type('string')]
58
        public ?string $partnerCode = null,
59
60
        #[Serializer\Type('string')]
61
        public ?string $hubCode = null,
62
63
        #[Serializer\Type('string')]
64
        public ?string $hubName = null,
65
66
        #[Serializer\Type('string')]
67
        public ?string $hubNameEn = null,
68
69
        #[Serializer\Type('bool')]
70
        public ?bool $isDrive = null,
71
    ){
72 2
    }
73
}
74