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

ProcessMemoryMap::findByNameRegex()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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