OpcodeFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 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\PhpInternals\Opcodes;
15
16
final class OpcodeFactory
17
{
18
    /** @var array<string, class-string<Opcode>> */
19
    private const VERSION_MAP = [
20
        'v70' => OpcodeV70::class,
21
        'v71' => OpcodeV71::class,
22
        'v72' => OpcodeV72::class,
23
        'v73' => OpcodeV73::class,
24
        'v74' => OpcodeV74::class,
25
        'v80' => OpcodeV80::class,
26
        'v81' => OpcodeV81::class,
27
    ];
28
29
    /**
30
     * @template TVersion of key-of<self::VERSION_MAP>
31
     * @param TVersion $version
0 ignored issues
show
Bug introduced by
The type PhpProfiler\Lib\PhpInternals\Opcodes\TVersion was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
     * @return (
0 ignored issues
show
Documentation Bug introduced by
The doc comment ( at position 1 could not be parsed: the token is null at position 1.
Loading history...
33
     *   TVersion is 'v70' ? OpcodeV70 :
34
     *   TVersion is 'v71' ? OpcodeV71 :
35
     *   TVersion is 'v72' ? OpcodeV72 :
36
     *   TVersion is 'v73' ? OpcodeV73 :
37
     *   TVersion is 'v74' ? OpcodeV74 :
38
     *   TVersion is 'v80' ? OpcodeV80 :
39
     *   OpcodeV81
40
     * )
41
     */
42
    public function create(string $version, int $opcode): Opcode
43
    {
44
        return match ($version) {
45
            'v70' => new OpcodeV70($opcode),
46
            'v71' => new OpcodeV71($opcode),
47
            'v72' => new OpcodeV72($opcode),
48
            'v73' => new OpcodeV73($opcode),
49
            'v74' => new OpcodeV74($opcode),
50
            'v80' => new OpcodeV80($opcode),
51
            'v81' => new OpcodeV81($opcode),
52
        };
53
    }
54
}
55