ProcessMemoryMap::findByNameRegex()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 9
rs 10
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