Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — master ( ffec95...9c7550 )
by Henrique
02:45
created

NotEmoji::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use function implode;
17
use function is_string;
18
use function preg_match;
19
20
/**
21
 * Validates if the input does not contain an emoji.
22
 *
23
 * @author Mazen Touati <[email protected]>
24
 */
25
final class NotEmoji extends AbstractRule
26
{
27
    private const GROUPS = [
28
        '[\x{1F385}-\x{1F9E6}]',
29
        '[\x{1F331}-\x{1F9A2}]',
30
        '[\x{1F32D}-\x{1F9C2}]',
31
        '[\x{1F300}-\x{1F9F3}]',
32
        '[\x{1F004}-\x{1F9FF}]',
33
        '[\x{1F399}-\x{1F9FE}]',
34
        '[\x{1F170}-\x{1F6D0}]',
35
        '[\x{1F38C}-\x{1F6A9}]',
36
        '[\x{261D}]',
37
        '[\x{2620}]',
38
        '[\x{2639}-\x{263A}]',
39
        '[\x{26D1}]',
40
        '[\x{26F7}-\x{26F9}]',
41
        '[\x{270A}-\x{270D}]',
42
        '[\x{2763}-\x{2764}]',
43
        '[\x{2618}]',
44
        '[\x{2615}]',
45
        '[\x{231A}-\x{231B}]',
46
        '[\x{23F0}-\x{23F3}]',
47
        '[\x{2600}-\x{2604}]',
48
        '[\x{2614}]',
49
        '[\x{2668}]',
50
        '[\x{2693}]',
51
        '[\x{26A1}]',
52
        '[\x{26C4}-\x{26C5}]',
53
        '[\x{26C8}]',
54
        '[\x{26E9}-\x{26EA}]',
55
        '[\x{26F0}-\x{26F5}]',
56
        '[\x{26FA}]',
57
        '[\x{26FD}]',
58
        '[\x{2708}]',
59
        '[\x{2744}]',
60
        '[\x{2B50}]',
61
        '[\x{265F}-\x{2660}]',
62
        '[\x{2663}-\x{2666}]',
63
        '[\x{26BD}-\x{26BE}]',
64
        '[\x{26F3}]',
65
        '[\x{26F8}]',
66
        '[\x{2728}]',
67
        '[\x{2328}]',
68
        '[\x{260E}]',
69
        '[\x{2692}-\x{2699}]',
70
        '[\x{26B0}-\x{26B1}]',
71
        '[\x{26CF}]',
72
        '[\x{26D3}]',
73
        '[\x{2702}]',
74
        '[\x{2709}]',
75
        '[\x{270F}]',
76
        '[\x{2712}]',
77
        '[\x{00A9}]',
78
        '[\x{00AE}]',
79
        '[\x{203C}]',
80
        '[\x{2049}]',
81
        '[\x{2122}]',
82
        '[\x{2139}]',
83
        '[\x{2194}-\x{2199}]',
84
        '[\x{21A9}-\x{21AA}]',
85
        '[\x{23CF}]',
86
        '[\x{23EA}-\x{23EF}]',
87
        '[\x{23F8}-\x{23FA}]',
88
        '[\x{24C2}]',
89
        '[\x{25AA}-\x{25AB}]',
90
        '[\x{25B6}]',
91
        '[\x{25C0}]',
92
        '[\x{25FB}-\x{25FE}]',
93
        '[\x{2611}]',
94
        '[\x{2622}-\x{2623}]',
95
        '[\x{2626}]',
96
        '[\x{262A}]',
97
        '[\x{262E}-\x{262F}]',
98
        '[\x{2638}]',
99
        '[\x{2640}-\x{2642}]',
100
        '[\x{2648}-\x{2653}]',
101
        '[\x{267B}]',
102
        '[\x{267E}-\x{267F}]',
103
        '[\x{2695}]',
104
        '[\x{23E9}]',
105
        '[\x{269B}-\x{269C}]',
106
        '[\x{26A0}]',
107
        '[\x{26AA}-\x{26AB}]',
108
        '[\x{26CE}]',
109
        '[\x{26D4}]',
110
        '[\x{2705}]',
111
        '[\x{2714}-\x{2716}]',
112
        '[\x{271D}]',
113
        '[\x{2721}]',
114
        '[\x{2733}-\x{2734}]',
115
        '[\x{2747}]',
116
        '[\x{274C}-\x{274E}]',
117
        '[\x{2753}-\x{2757}]',
118
        '[\x{2795}-\x{2797}]',
119
        '[\x{27A1}]',
120
        '[\x{27B0}]',
121
        '[\x{27BF}]',
122
        '[\x{2934}-\x{2935}]',
123
        '[\x{2B05}-\x{2B07}]',
124
        '[\x{2B1B}-\x{2B1C}]',
125
        '[\x{2B55}]',
126
        '[\x{3030}]',
127
        '[\x{303D}]',
128
        '[\x{3297}-\x{3299}]',
129
        '[\x{1F1E6}-\x{1F1FF}]',
130
        '\x{0023}\x{20E3}',
131
        '\x{0023}\x{FE0F}\x{20E3}',
132
        '\x{002A}\x{20E3}',
133
        '\x{002A}\x{FE0F}\x{20E3}',
134
        '\x{0030}\x{20E3}',
135
        '\x{0030}\x{FE0F}\x{20E3}',
136
        '\x{0031}\x{20E3}',
137
        '\x{0031}\x{FE0F}\x{20E3}',
138
        '\x{0032}\x{20E3}',
139
        '\x{0032}\x{FE0F}\x{20E3}',
140
        '\x{0033}\x{20E3}',
141
        '\x{0033}\x{FE0F}\x{20E3}',
142
        '\x{0034}\x{20E3}',
143
        '\x{0034}\x{FE0F}\x{20E3}',
144
        '\x{0035}\x{20E3}',
145
        '\x{0035}\x{FE0F}\x{20E3}',
146
        '\x{0036}\x{20E3}',
147
        '\x{0036}\x{FE0F}\x{20E3}',
148
        '\x{0037}\x{20E3}',
149
        '\x{0037}\x{FE0F}\x{20E3}',
150
        '\x{0038}\x{20E3}',
151
        '\x{0038}\x{FE0F}\x{20E3}',
152
        '\x{0039}\x{20E3}',
153
        '\x{0039}\x{FE0F}\x{20E3}',
154
    ];
155
156
    /**
157
     * {@inheritdoc}
158
     */
159 29
    public function validate($input): bool
160
    {
161 29
        if (!is_string($input)) {
162 3
            return false;
163
        }
164
165 26
        return 0 === preg_match('/'.implode('|', self::GROUPS).'/mu', $input);
166
    }
167
}
168