GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Surrogate::isValidBlock()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
namespace UCD\Unicode;
4
5
use UCD\Unicode\Character\Properties\General;
6
use UCD\Unicode\Character\Properties\General\Block;
7
use UCD\Exception\InvalidArgumentException;
8
9
class Surrogate extends NonCharacter
10
{
11
    /**
12
     * @param Codepoint $codepoint
13
     * @param General $generalProperties
14
     * @throws InvalidArgumentException
15
     */
16
    public function __construct(Codepoint $codepoint, General $generalProperties)
17
    {
18
        if (!$this->isValidBlock($generalProperties->getBlock())) {
19
            throw new InvalidArgumentException('Surrogate should reside within a surrogate block');
20
        }
21
22
        parent::__construct($codepoint, $generalProperties);
23
    }
24
25
    /**
26
     * @param Block $block
27
     * @return bool
28
     */
29
    private function isValidBlock(Block $block)
30
    {
31
        static $valid = [
32
            Block::HIGH_PRIVATE_USE_SURROGATES => true,
33
            Block::HIGH_SURROGATES => true,
34
            Block::LOW_SURROGATES => true
35
        ];
36
37
        return array_key_exists($block->getValue(), $valid);
38
    }
39
}