Passed
Pull Request — 0.6.x (#203)
by
unknown
03:01 queued 01:32
created

Elf64CachedSymbolResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 17
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 0 9 2
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