Completed
Push — master ( 1a2e45...fc6b0c )
by Shinji
15s queued 11s
created

UnrelocatedProcessMemoryByteReader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A createSliceAsString() 0 5 1
A __construct() 0 4 1
A offsetGet() 0 3 1
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\ByteStream;
15
16
use PhpProfiler\Lib\Process\MemoryMap\ProcessModuleMemoryMapInterface;
17
18
final class UnrelocatedProcessMemoryByteReader implements ByteReaderInterface
19
{
20
    use ByteReaderDisableWriteAccessTrait;
21
22
    private ByteReaderInterface $byte_reader;
23
    private ProcessModuleMemoryMapInterface $module_memory_map;
24
25
    /**
26
     * UnrelocatedProcessMemoryByteReader constructor.
27
     * @param ByteReaderInterface $byte_reader
28
     * @param ProcessModuleMemoryMapInterface $module_memory_map
29
     */
30
    public function __construct(ByteReaderInterface $byte_reader, ProcessModuleMemoryMapInterface $module_memory_map)
31
    {
32
        $this->byte_reader = $byte_reader;
33
        $this->module_memory_map = $module_memory_map;
34
    }
35
36
    public function offsetExists($offset): bool
37
    {
38
        return isset($this->byte_reader[$this->module_memory_map->getMemoryAddressFromOffset($offset)]);
39
    }
40
41
    public function offsetGet($offset): int
42
    {
43
        return $this->byte_reader[$this->module_memory_map->getMemoryAddressFromOffset($offset)];
44
    }
45
46
    public function createSliceAsString(int $offset, int $size): string
47
    {
48
        return $this->byte_reader->createSliceAsString(
49
            $this->module_memory_map->getMemoryAddressFromOffset($offset),
50
            $size
51
        );
52
    }
53
}
54