ProcessMemoryMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findByNameRegex() 0 9 3
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\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