Passed
Push — develop ( cb60d7...ef7d65 )
by Maarten de
07:14
created

TokenizerException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentToken() 0 3 1
A __construct() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cloudstek\SCIM\FilterParser\Exception;
6
7
use Cloudstek\SCIM\FilterParser\Tokenizer;
8
use Nette\Tokenizer\Token;
9
10
/**
11
 * Tokenizer exception.
12
 */
13
class TokenizerException extends \Nette\Tokenizer\Exception
14
{
15
    private ?Token $currentToken = null;
16
17
    /**
18
     * Invalid value path exception.
19
     *
20
     * @param string                $message  Exception message.
21
     * @param Tokenizer\Stream|null $stream   Tokenizer stream.
22
     * @param int                   $code     Exception code.
23
     * @param \Throwable|null       $previous Previous exception.
24
     */
25
    public function __construct(
26
        $message,
27
        ?Tokenizer\Stream $stream = null,
28
        int $code = 0,
29
        \Throwable $previous = null
30
    ) {
31
        parent::__construct($message, $code, $previous);
32
33
        if ($stream !== null) {
34
            $this->currentToken = $stream->currentToken();
35
        }
36
    }
37
38
    /**
39
     * Get token at which exception was thrown.
40
     *
41
     * @return Token|null
42
     */
43
    public function getCurrentToken(): ?Token
44
    {
45
        return $this->currentToken;
46
    }
47
}
48