Elf64ProgramHeaderEntry::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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

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
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Lib\Elf\Structure\Elf64;
15
16
use PhpProfiler\Lib\Integer\UInt64;
17
18
final class Elf64ProgramHeaderEntry
19
{
20
    public const PT_NULL = 0;
21
    public const PT_LOAD = 1;
22
    public const PT_DYNAMIC = 2;
23
    public const PT_INTERP = 3;
24
    public const PT_NOTE = 4;
25
    public const PT_SHLIB = 5;
26
    public const PT_PHDR = 6;
27
    public const PT_LOPROC = 0x70000000;
28
    public const PT_HIPROC = 0x7fffffff;
29
30
    public const PF_X = 1;
31
    public const PF_W = 2;
32
    public const PF_R = 4;
33
    public const PF_MASKPROC = 0xf000000;
34
35
    public function __construct(
36
        public int $p_type, // Elf64_Word
37
        public int $p_flags, // Elf64_Word
38
        public UInt64 $p_offset, // Elf64_Off
39
        public UInt64 $p_vaddr, // Elf64_Addr
40
        public UInt64 $p_paddr, // Elf64_Addr
41
        public UInt64 $p_filesz, // Elf64_Xword
42
        public UInt64 $p_memsz, // Elf64_Xword
43
        public UInt64 $p_align // Elf64_Xword
44
    ) {
45
    }
46
47
    public function isLoad(): bool
48
    {
49
        return $this->p_type === self::PT_LOAD;
50
    }
51
52
    public function isDynamic(): bool
53
    {
54
        return $this->p_type === self::PT_DYNAMIC;
55
    }
56
}
57