RegionsSummary::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 12
dl 0
loc 14
rs 10
c 0
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
/**
4
 * This file is part of the reliforp/reli-prof 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 Reli\Lib\PhpProcessReader\PhpMemoryReader\RegionAnalyzer\Result;
15
16
final class RegionsSummary
17
{
18
    public function __construct(
19
        public int $zend_mm_heap_total,
20
        public int $zend_mm_heap_usage,
21
        public int $zend_mm_chunk_total,
22
        public int $zend_mm_chunk_usage,
23
        public int $zend_mm_huge_total,
24
        public int $zend_mm_huge_usage,
25
        public int $vm_stack_total,
26
        public int $vm_stack_usage,
27
        public int $compiler_arena_total,
28
        public int $compiler_arena_usage,
29
        public int $possible_allocation_overhead_total,
30
        public int $possible_array_overhead_total,
31
    ) {
32
    }
33
34
    /**
35
     * @return array<string, int>
36
     */
37
    public function toArray(): array
38
    {
39
        return [
40
            'zend_mm_heap_total' => $this->zend_mm_heap_total,
41
            'zend_mm_heap_usage' => $this->zend_mm_heap_usage,
42
            'zend_mm_chunk_total' => $this->zend_mm_chunk_total,
43
            'zend_mm_chunk_usage' => $this->zend_mm_chunk_usage,
44
            'zend_mm_huge_total' => $this->zend_mm_huge_total,
45
            'zend_mm_huge_usage' => $this->zend_mm_huge_usage,
46
            'vm_stack_total' => $this->vm_stack_total,
47
            'vm_stack_usage' => $this->vm_stack_usage,
48
            'compiler_arena_total' => $this->compiler_arena_total,
49
            'compiler_arena_usage' => $this->compiler_arena_usage,
50
            'possible_allocation_overhead_total' => $this->possible_allocation_overhead_total,
51
            'possible_array_overhead_total' => $this->possible_array_overhead_total,
52
        ];
53
    }
54
}
55