Passed
Push — 0.6.x ( 9a1948...a98caa )
by Shinji
03:23 queued 01:32
created

ProcessMemoryMap   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findByNameRegex() 0 9 3
A __construct() 0 3 1
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\Process\MemoryMap;
15
16
final class ProcessMemoryMap
17
{
18
    /** @param ProcessMemoryArea[] $memory_areas */
19
    public function __construct(
20
        private array $memory_areas,
21
    ) {
22
    }
23
24
    /** @return ProcessMemoryArea[] */
25
    public function findByNameRegex(string $regex): array
26
    {
27
        $result = [];
28
        foreach ($this->memory_areas as $memory_area) {
29
            if (preg_match('{' . $regex . '}', $memory_area->name)) {
30
                $result[] = $memory_area;
31
            }
32
        }
33
        return $result;
34
    }
35
}
36