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

Elf64SectionHeaderTable   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 30
rs 10
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findSymbolTableEntry() 0 8 3
A __construct() 0 5 1
A findStringTableEntry() 0 8 4
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