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.
Completed
Push — master ( ff3008...d4aa5e )
by Nicholas
03:20
created

CodepointSearchByIteration   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 1
cbo 5
dl 0
loc 47
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getByCodepoint() 0 10 3
A getByCodepoints() 0 6 1
A unionAgainstCodepoints() 0 8 3
getAll() 0 1 ?
1
<?php
2
3
namespace UCD\Unicode\Character\Repository\Capability;
4
5
use UCD\Unicode\Character;
6
use UCD\Unicode\Character\Repository\CharacterNotFoundException;
7
use UCD\Unicode\Codepoint;
8
use UCD\Unicode\CodepointAssigned;
9
10
trait CodepointSearchByIteration
11
{
12
    /**
13
     * @param Codepoint $codepoint
14
     * @throws CharacterNotFoundException
15
     * @return CodepointAssigned
16
     */
17
    public function getByCodepoint(Codepoint $codepoint)
18
    {
19
        foreach ($this->getAll() as $character) {
20
            if ($codepoint->equals($character->getCodepoint())) {
21
                return $character;
22
            }
23
        }
24
25
        throw CharacterNotFoundException::withCodepoint($codepoint);
26
    }
27
28
    /**
29
     * @param Codepoint\Collection $codepoints
30
     * @return Character\Collection
31
     */
32
    public function getByCodepoints(Codepoint\Collection $codepoints)
33
    {
34
        return new Character\Collection(
35
            $this->unionAgainstCodepoints($codepoints)
36
        );
37
    }
38
39
    /**
40
     * @param Codepoint\Collection $codepoints
41
     * @return \Generator
42
     */
43
    protected function unionAgainstCodepoints(Codepoint\Collection $codepoints)
44
    {
45
        foreach ($this->getAll() as $character) {
46
            if ($codepoints->has($character->getCodepoint())) {
47
                yield $character;
48
            }
49
        }
50
    }
51
52
    /**
53
     * @return CodepointAssigned[]
54
     */
55
    abstract public function getAll();
56
}