Passed
Push — lexer1 ( 54a5b3...04fbeb )
by Martin
44:16 queued 29:14
created

DoctrineLexer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 5
c 1
b 1
f 1
dl 0
loc 20
ccs 5
cts 6
cp 0.8333
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getLookaheadType() 0 9 2
A isPre200() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MartinGeorgiev\Utils;
6
7
use Doctrine\ORM\Query\Lexer;
8
9
/**
10
 * @internal
11
 */
12
final class DoctrineLexer
13
{
14 20
    public static function isPre200(Lexer $lexer): bool
15
    {
16
        // @phpstan-ignore-next-line
17 20
        return \is_array($lexer->lookahead);
18
    }
19
20
    /**
21
     * @return mixed|null
22
     */
23 20
    public static function getLookaheadType(Lexer $lexer)
24
    {
25 20
        if (self::isPre200($lexer)) {
26
            // @phpstan-ignore-next-line
27
            return $lexer->lookahead['type'];
28
        }
29
30
        // @phpstan-ignore-next-line
31 20
        return $lexer->lookahead?->type;
32
    }
33
}
34