Passed
Pull Request — 0.6.x (#205)
by
unknown
02:28 queued 36s
created

Elf64CachedSymbolResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 9
rs 10
c 1
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\SymbolResolver;
15
16
use Reli\Lib\Elf\Structure\Elf64\Elf64SymbolTableEntry;
17
18
final class Elf64CachedSymbolResolver implements Elf64SymbolResolver
19
{
20
    public function __construct(
21
        private Elf64SymbolResolver $resolver,
22
        private Elf64SymbolCache $symbol_cache,
23
    ) {
24
    }
25
26
    public function resolve(string $symbol_name): Elf64SymbolTableEntry
27
    {
28
        if (!$this->symbol_cache->has($symbol_name)) {
29
            $this->symbol_cache->set(
30
                $symbol_name,
31
                $this->resolver->resolve($symbol_name),
32
            );
33
        }
34
        return $this->symbol_cache->get($symbol_name);
35
    }
36
}
37