NonUnicodeCharacterException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildMessage() 0 5 1
A getCharacter() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\Lexer\Runtime\Unicode\Exception;
6
7
use RuntimeException;
8
use Throwable;
9
10
use function dechex;
11
use function strtoupper;
12
13
final class NonUnicodeCharacterException extends RuntimeException implements ExceptionInterface
14
{
15
16
    /**
17
     * @var int
18
     */
19
    private $character;
20
21 5
    public function __construct(int $character, Throwable $previous = null)
22
    {
23 5
        $this->character = $character;
24 5
        parent::__construct($this->buildMessage(), 0, $previous);
25 5
    }
26
27 5
    private function buildMessage(): string
28
    {
29 5
        $hexCode = strtoupper(dechex($this->character));
30
31 5
        return "Character 0x{$hexCode} is not in Unicode range";
32
    }
33
34 1
    public function getCharacter(): int
35
    {
36 1
        return $this->character;
37
    }
38
}
39