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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A isValidBlock() 0 10 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
}