InvalidTokenException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createForBuffer() 0 5 1
1
<?php declare(strict_types=1);
2
/**
3
 * portable-game-notation (https://github.com/chesszebra/portable-game-notation)
4
 *
5
 * @link https://github.com/chesszebra/portable-game-notation for the canonical source repository
6
 * @copyright Copyright (c) 2017 Chess Zebra (https://chesszebra.com)
7
 * @license https://github.com/chesszebra/portable-game-notation/blob/master/LICENSE.md MIT
8
 */
9
10
namespace ChessZebra\PortableGameNotation\Lexer\Exception;
11
12
use RuntimeException;
13
14
/**
15
 * An exception that is thrown when a token was found that could not be matched.
16
 */
17
final class InvalidTokenException extends RuntimeException
18
{
19
    /**
20
     * Creates a new exception for the given buffer.
21
     *
22
     * @param string $buffer The buffer to create the exception for.
23
     * @return InvalidTokenException
24
     */
25
    public static function createForBuffer(string $buffer): InvalidTokenException
26
    {
27
        $msg = sprintf('An invalid token was given. Buffer: "%s"', $buffer);
28
29
        return new self($msg);
30
    }
31
}
32