Completed
Push — master ( 8f139f...a8687a )
by Joachim
04:58
created

GSM7   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 19
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A isGSM7() 0 13 3
1
<?php
2
namespace Loevgaard\Linkmobility\GSM7;
3
4
class GSM7
5
{
6
    const ALPHABET = ['_', '-', ',', ';', ':', '!', '¡', '?', '¿', '.', "'", '"', '(', ')', '[', ']', '{', '}', '§', '@', '*', '/', '\\', '&', '#', '%', '^', '+', '<', '=', '>', '|', '~', '¤', '$', '£', '¥', '€', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'A', 'à', 'å', 'Å', 'ä', 'Ä', 'æ', 'Æ', 'b', 'B', 'c', 'C', 'Ç', 'd', 'D', 'e', 'E', 'é', 'É', 'è', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'ì', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'ñ', 'Ñ', 'o', 'O', 'ò', 'ö', 'Ö', 'ø', 'Ø', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 'ß', 't', 'T', 'u', 'U', 'ù', 'ü', 'Ü', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z', 'Γ', 'Δ', 'Θ', 'Λ', 'Ξ', 'Π', 'Σ', 'Φ', 'Ψ', 'Ω'];
7
    const DOUBLES = ['|', '^', '€', '{', '}', '[', ']', '~', '\\'];
8
9
    public static function isGSM7(string $str) : bool
10
    {
11
        $alphabet = self::ALPHABET;
12
13
        $len = mb_strlen($str);
14
        for ($i = 0; $i < $len; $i++) {
15
            if (!in_array($str[$i], $alphabet)) {
16
                return false;
17
            }
18
        }
19
20
        return true;
21
    }
22
}
23