Passed
Pull Request — master (#44)
by Shinji
01:40
created

OpcodeFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 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
    ];
27
28
    /**
29
     * @template TVersion of key-of<self::VERSION_MAP>
30
     * @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...
31
     * @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...
32
     *   TVersion is 'v70' ? OpcodeV70 :
33
     *   TVersion is 'v71' ? OpcodeV71 :
34
     *   TVersion is 'v72' ? OpcodeV72 :
35
     *   TVersion is 'v73' ? OpcodeV73 :
36
     *   TVersion is 'v74' ? OpcodeV74 :
37
     *   OpcodeV80
38
     * )
39
     */
40
    public function create(string $version, int $opcode): Opcode
41
    {
42
        return match ($version) {
43
            'v71' => new OpcodeV71($opcode),
44
            'v72' => new OpcodeV72($opcode),
45
            'v73' => new OpcodeV73($opcode),
46
            'v74' => new OpcodeV74($opcode),
47
            'v80' => new OpcodeV80($opcode),
48
        };
49
    }
50
}
51