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

Elf64SectionHeaderTable::findSymbolTableEntry()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 0
dl 0
loc 8
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\Elf\Structure\Elf64;
15
16
final class Elf64SectionHeaderTable
17
{
18
    /** @var Elf64SectionHeaderEntry[] */
19
    private array $entries;
20
21
    public function __construct(
22
        private Elf64StringTable $section_name_table,
23
        Elf64SectionHeaderEntry ...$entries
24
    ) {
25
        $this->entries = $entries;
26
    }
27
28
    public function findSymbolTableEntry(): ?Elf64SectionHeaderEntry
29
    {
30
        foreach ($this->entries as $entry) {
31
            if ($entry->isSymbolTable()) {
32
                return $entry;
33
            }
34
        }
35
        return null;
36
    }
37
38
    public function findStringTableEntry(): ?Elf64SectionHeaderEntry
39
    {
40
        foreach ($this->entries as $entry) {
41
            if ($entry->isStringTable() and $this->section_name_table->lookup($entry->sh_name) === '.strtab') {
42
                return $entry;
43
            }
44
        }
45
        return null;
46
    }
47
}
48