├── .gitattributes ├── .gitignore ├── .php_cs.dist ├── .styleci.yml ├── README.md ├── composer.json ├── phpunit.xml ├── src └── Regex.php └── tests ├── RegexTest.php └── TestCase.php /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | docker-compose.override.yml 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | .php_cs.cache 15 | .DS_Store 16 | composer.lock 17 | .phpunit.cache/test-results 18 | phpunit.xml.bak 19 | -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | ['syntax' => 'short'], 8 | 'binary_operator_spaces' => [ 9 | 'default' => 'single_space', 10 | 'operators' => ['=>' => null] 11 | ], 12 | 'blank_line_after_namespace' => true, 13 | 'blank_line_after_opening_tag' => true, 14 | 'blank_line_before_statement' => [ 15 | 'statements' => ['return'] 16 | ], 17 | 'braces' => true, 18 | 'cast_spaces' => true, 19 | 'class_attributes_separation' => [ 20 | 'elements' => ['method'] 21 | ], 22 | 'class_definition' => true, 23 | 'concat_space' => [ 24 | 'spacing' => 'none' 25 | ], 26 | 'declare_equal_normalize' => true, 27 | 'elseif' => true, 28 | 'encoding' => true, 29 | 'full_opening_tag' => true, 30 | 'fully_qualified_strict_types' => true, // added by Shift 31 | 'function_declaration' => true, 32 | 'function_typehint_space' => true, 33 | 'heredoc_to_nowdoc' => true, 34 | 'include' => true, 35 | 'increment_style' => ['style' => 'post'], 36 | 'indentation_type' => true, 37 | 'linebreak_after_opening_tag' => true, 38 | 'line_ending' => true, 39 | 'lowercase_cast' => true, 40 | 'lowercase_constants' => true, 41 | 'lowercase_keywords' => true, 42 | 'lowercase_static_reference' => true, // added from Symfony 43 | 'magic_method_casing' => true, // added from Symfony 44 | 'magic_constant_casing' => true, 45 | 'method_argument_space' => true, 46 | 'native_function_casing' => true, 47 | 'no_alias_functions' => true, 48 | 'no_extra_blank_lines' => [ 49 | 'tokens' => [ 50 | 'extra', 51 | 'throw', 52 | 'use', 53 | 'use_trait', 54 | ] 55 | ], 56 | 'no_blank_lines_after_class_opening' => true, 57 | 'no_blank_lines_after_phpdoc' => true, 58 | 'no_closing_tag' => true, 59 | 'no_empty_phpdoc' => true, 60 | 'no_empty_statement' => true, 61 | 'no_leading_import_slash' => true, 62 | 'no_leading_namespace_whitespace' => true, 63 | 'no_mixed_echo_print' => [ 64 | 'use' => 'echo' 65 | ], 66 | 'no_multiline_whitespace_around_double_arrow' => true, 67 | 'multiline_whitespace_before_semicolons' => [ 68 | 'strategy' => 'no_multi_line' 69 | ], 70 | 'no_short_bool_cast' => true, 71 | 'no_singleline_whitespace_before_semicolons' => true, 72 | 'no_spaces_after_function_name' => true, 73 | 'no_spaces_around_offset' => true, 74 | 'no_spaces_inside_parenthesis' => true, 75 | 'no_trailing_comma_in_list_call' => true, 76 | 'no_trailing_comma_in_singleline_array' => true, 77 | 'no_trailing_whitespace' => true, 78 | 'no_trailing_whitespace_in_comment' => true, 79 | 'no_unneeded_control_parentheses' => true, 80 | 'no_unreachable_default_argument_value' => true, 81 | 'no_unused_imports' => true, 82 | 'no_useless_return' => true, 83 | 'no_whitespace_before_comma_in_array' => true, 84 | 'no_whitespace_in_blank_line' => true, 85 | 'normalize_index_brace' => true, 86 | 'not_operator_with_successor_space' => true, 87 | 'object_operator_without_whitespace' => true, 88 | 'ordered_imports' => ['sortAlgorithm' => 'alpha'], 89 | 'phpdoc_indent' => true, 90 | 'phpdoc_inline_tag' => true, 91 | 'phpdoc_no_access' => true, 92 | 'phpdoc_no_package' => true, 93 | 'phpdoc_no_useless_inheritdoc' => true, 94 | 'phpdoc_scalar' => true, 95 | 'phpdoc_single_line_var_spacing' => true, 96 | 'phpdoc_summary' => true, 97 | 'phpdoc_to_comment' => true, 98 | 'phpdoc_trim' => true, 99 | 'phpdoc_types' => true, 100 | 'phpdoc_var_without_name' => true, 101 | 'psr4' => true, 102 | 'self_accessor' => true, 103 | 'short_scalar_cast' => true, 104 | 'simplified_null_return' => false, // disabled by Shift 105 | 'single_blank_line_at_eof' => true, 106 | 'single_blank_line_before_namespace' => true, 107 | 'single_class_element_per_statement' => true, 108 | 'single_import_per_statement' => true, 109 | 'single_line_after_imports' => true, 110 | 'single_line_comment_style' => [ 111 | 'comment_types' => ['hash'] 112 | ], 113 | 'single_quote' => true, 114 | 'space_after_semicolon' => true, 115 | 'standardize_not_equals' => true, 116 | 'switch_case_semicolon_to_colon' => true, 117 | 'switch_case_space' => true, 118 | 'ternary_operator_spaces' => true, 119 | 'trailing_comma_in_multiline_array' => true, 120 | 'trim_array_spaces' => true, 121 | 'unary_operator_spaces' => true, 122 | 'visibility_required' => [ 123 | 'elements' => ['method', 'property'] 124 | ], 125 | 'whitespace_after_comma_in_array' => true, 126 | ]; 127 | 128 | 129 | $finder = Finder::create() 130 | ->in([ 131 | __DIR__ . '/src', 132 | __DIR__ . '/tests', 133 | ]) 134 | ->name('*.php') 135 | ->notName('*.blade.php') 136 | ->ignoreDotFiles(true) 137 | ->ignoreVCS(true); 138 | 139 | return Config::create() 140 | ->setFinder($finder) 141 | ->setRules($rules) 142 | ->setRiskyAllowed(true) 143 | ->setUsingCache(true); 144 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | finder: 4 | not-name: 5 | - index.php 6 | - server.php 7 | enabled: 8 | - fully_qualified_strict_types 9 | js: 10 | finder: 11 | not-name: 12 | - webpack.mix.js 13 | exclude: 14 | - public 15 | not-path: 16 | - dist 17 | css: true -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Regex 2 | 3 | A set of ready-made regex helper methods for use in your Laravel application. 4 | 5 | [![Latest Stable Version](http://poser.pugx.org/hotmeteor/regex/v)](https://packagist.org/packages/hotmeteor/regex) 6 | 7 | ## Installation 8 | 9 | ```shell 10 | composer require hotmeteor/regex 11 | ``` 12 | 13 | ## Usage 14 | 15 | Regex comes with a set of common regex patterns that are ready to use. These patterns can be used to either **replace** or **match** against values. Every pattern is both case-insensitive and able to interpret unicode characters, and should support all languages. 16 | 17 | Additionally, beyond the methods below both the underlying `match` and `replace` methods are exposed to pass in custom patterns. 18 | 19 | ### Match 20 | 21 | Match methods return true or false depending on if the subject value contains anything but the expected pattern. 22 | 23 | You may optional allow whitespace by passing `true` as a second parameter. 24 | 25 | #### Methods 26 | 27 | ```php 28 | Regex::isAlpha($subject, $allowWhitespace = false) 29 | ``` 30 | Checks if the value contains anything but letters. 31 | 32 | *** 33 | 34 | ```php 35 | Regex::isAlphanumeric($subject, $allowWhitespace = false) 36 | ``` 37 | Checks if the value contains anything but letters and numbers. 38 | 39 | *** 40 | 41 | ```php 42 | Regex::isAlphadash($subject, $allowWhitespace = false) 43 | ``` 44 | Checks if the value contains anything but letters, numbers, and `.-_`. 45 | 46 | *** 47 | 48 | ```php 49 | Regex::isDigits($subject, $allowWhitespace = false) 50 | ``` 51 | Checks if the value contains anything but integers. 52 | 53 | *** 54 | 55 | ```php 56 | Regex::isNumeric($subject) 57 | ``` 58 | Checks if the value contains anything but numeric values, including decimals and negative numbers. Does not allow for whitespace. 59 | 60 | *** 61 | 62 | ```php 63 | Regex::isUuid($subject) 64 | ``` 65 | Checks if the value is a UUID. Does not allow for whitespace. 66 | 67 | *** 68 | 69 | ```php 70 | Regex::isIp($subject) // or 71 | Regex::isIpv4($subject) 72 | ``` 73 | Checks if the value is an IPv4 address. Does not allow for whitespace. 74 | 75 | *** 76 | 77 | ```php 78 | Regex::isIpv6($subject) 79 | ``` 80 | Checks if the value is an IPv6 address. Does not allow for whitespace. 81 | 82 | ### Replace 83 | 84 | Replace methods replace anything in the subject value that doesn't match the pattern with the provided replacement. 85 | 86 | The default replacement is nothing: it just removes the character. 87 | 88 | #### Methods 89 | ```php 90 | Regex::alpha($subject, $replace = '') 91 | ``` 92 | Replaces all characters in the subject except letters. 93 | 94 | *** 95 | 96 | ```php 97 | Regex::alphanumeric($subject, $replace = '') 98 | ``` 99 | Replaces all characters in the subject except letters and numbers. 100 | 101 | *** 102 | 103 | ```php 104 | Regex::alphadash($subject, $replace = '') 105 | ``` 106 | Replaces all characters in the subject except letters, numbers, and `.-_`. 107 | 108 | *** 109 | 110 | ```php 111 | Regex::digits($subject, $replace = '') 112 | ``` 113 | Replaces all characters in the subject except integers. 114 | 115 | *** 116 | 117 | ```php 118 | Regex::numeric($subject, $replace = '') 119 | ``` 120 | Replaces all characters in the subject except numeric values, including decimals and negative numbers. 121 | 122 | *** 123 | 124 | ```php 125 | Regex::uuid($subject) 126 | ``` 127 | Replaces all characters in the subject to form it into a UUID. Does not accept a replacement value. 128 | 129 | *** 130 | 131 | ```php 132 | Regex::ip($subject) // or 133 | Regex::ipv4($subject) 134 | ``` 135 | Replaces all characters in the subject to form it into an IPv4 address. Does not accept a replacement value. 136 | 137 | ```php 138 | Regex::ipv6($subject) 139 | ``` 140 | Replaces all characters in the subject to form it into an IPv6 address. Does not accept a replacement value. 141 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hotmeteor/regex", 3 | "description": "A Regex library for Laravel.", 4 | "type": "library", 5 | "license": "MIT", 6 | "autoload": { 7 | "psr-4": { 8 | "Hotmeteor\\Regex\\": "src/" 9 | } 10 | }, 11 | "autoload-dev": { 12 | "psr-4": { 13 | "Tests\\": "tests/" 14 | } 15 | }, 16 | "authors": [ 17 | { 18 | "name": "Adam Campbell", 19 | "email": "adam@hotmeteor.com" 20 | } 21 | ], 22 | "require": { 23 | "php": "^8.2", 24 | "ext-json": "*", 25 | "illuminate/support": "^10.0|^11.0" 26 | }, 27 | "require-dev": { 28 | "mockery/mockery": "^1.4", 29 | "nunomaduro/collision": "^7.0|^8.0", 30 | "orchestra/testbench": "^8.0|^9.0", 31 | "phpunit/phpunit": "^10.0|^11.0" 32 | }, 33 | "scripts": { 34 | "post-autoload-dump": [ 35 | "@php ./vendor/bin/testbench package:discover --ansi" 36 | ] 37 | }, 38 | "config": { 39 | "optimize-autoloader": true, 40 | "preferred-install": "dist", 41 | "sort-packages": true 42 | }, 43 | "minimum-stability": "dev", 44 | "prefer-stable": true 45 | } 46 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | tests 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | src/ 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/Regex.php: -------------------------------------------------------------------------------- 1 | .*?(::))(?!.+\3)))\3?|([\dA-F]{1,4}(\3|:(?!$)|$)|\2))(?4){5}((?4){2}|((2[0-4]|1\d|[1-9])?\d|25[0-5])(\.(?7)){3})\z/i', false, '', ''); 261 | } 262 | 263 | /** 264 | * @param $subject 265 | * @param $pattern 266 | * @param bool $allowWhitespace 267 | * @param string $prefix 268 | * @param string $suffix 269 | * @return bool 270 | */ 271 | public static function match($subject, $pattern, bool $allowWhitespace = false, string $prefix = '/^[', string $suffix = ']+$/u'): bool 272 | { 273 | $result = preg_match(self::wrapMatchPattern($pattern, $allowWhitespace, $prefix, $suffix), $subject); 274 | 275 | return is_numeric($result) ? $result === 1 : $result; 276 | } 277 | 278 | /** 279 | * @param $subject 280 | * @param $pattern 281 | * @param string $glue 282 | * @param bool $allowWhitespace 283 | * @param string $prefix 284 | * @param string $suffix 285 | * @return string 286 | */ 287 | public static function glue($subject, $pattern, string $glue = '', bool $allowWhitespace = false, string $prefix = '/', string $suffix = '/'): string 288 | { 289 | preg_match(self::wrapMatchPattern($pattern, $allowWhitespace, $prefix, $suffix), $subject, $matches); 290 | 291 | array_shift($matches); 292 | 293 | return implode($glue, $matches); 294 | } 295 | 296 | /** 297 | * Wrap a replace pattern with boundaries. 298 | * 299 | * @param $pattern 300 | * @param $prefix 301 | * @param $suffix 302 | * @return string 303 | */ 304 | protected static function wrapReplacePattern($pattern, $prefix, $suffix): string 305 | { 306 | return implode('', [$prefix, $pattern, $suffix]); 307 | } 308 | 309 | /** 310 | * Wrap a match pattern with boundaries. 311 | * 312 | * @param $pattern 313 | * @param bool $allowWhitespace 314 | * @param $prefix 315 | * @param $suffix 316 | * @return string 317 | */ 318 | protected static function wrapMatchPattern($pattern, bool $allowWhitespace, $prefix, $suffix): string 319 | { 320 | return implode('', [$prefix, $allowWhitespace ? '\s' : '', $pattern, $suffix]); 321 | } 322 | } 323 | -------------------------------------------------------------------------------- /tests/RegexTest.php: -------------------------------------------------------------------------------- 1 | assertSame($expected, $result); 18 | } 19 | 20 | public static function providesReplacementSubjects() 21 | { 22 | return [ 23 | 24 | 'replace non alpha' => [ 25 | 'alpha', 26 | 'AbČdë', 27 | ], 28 | 29 | 'replace non alphanumeric' => [ 30 | 'alphanumeric', 31 | 'AbČdë12345', 32 | ], 33 | 34 | 'replace non alphadash' => [ 35 | 'alphadash', 36 | 'AbČdë12345.-_', 37 | ], 38 | 39 | 'replace non digits' => [ 40 | 'digits', 41 | '12345', 42 | ], 43 | 44 | 'replace non numeric' => [ 45 | 'numeric', 46 | '12345.-*', 47 | ], 48 | 49 | ]; 50 | } 51 | 52 | public function test_uuid_replace() 53 | { 54 | $expected = '440526d4-04bd-43c4-9ac5-55e15c835d0d'; 55 | 56 | $result = Regex::uuid('440526d4-04bd-43c4-9ac5-55e15c835d0d'); 57 | 58 | $this->assertSame($expected, $result); 59 | 60 | $result = Regex::uuid('4405 26d4-04bd43c4-9ac5 - 55e15c 835d0d '); 61 | 62 | $this->assertSame($expected, $result); 63 | } 64 | 65 | public function test_ipv4_replace() 66 | { 67 | $examples = [ 68 | '192.168.1.1' => '192.168.1.1', 69 | '192. 168. 1. 1' => '192.168.1.1', 70 | 'ip address: 192.168.1.1' => '192.168.1.1', 71 | 'ip address: 19216811' => '192.168.1.1', 72 | '255.255.255.255' => '255.255.255.255', 73 | '2 55 255.25 5255 ' => '255.255.255.255', 74 | ]; 75 | 76 | foreach ($examples as $ip => $expected) { 77 | $result = Regex::ipv4($ip); 78 | 79 | $this->assertSame($expected, $result); 80 | } 81 | } 82 | 83 | public function test_ipv6_replace() 84 | { 85 | $examples = [ 86 | '2001:0db8:85a3:0000:0000:8a2e:0370:7334' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 87 | '20 01: 0db8:85a3 : 0000:0 000:8a2e:0 370:7334 ' => '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 88 | 'FE80:0000:0000 0000:0202:B3FF:FE1E:8329' => 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329', 89 | 'F E80:0000:0 000:0 000:020 2:B3 FF FE1E: 8329' => 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329', 90 | 'FE80::8329' => 'FE80::8329', 91 | 'FE80::FFFF:8329' => 'FE80::FFFF:8329', 92 | 'FE80::B3FF:FFFF:8329' => 'FE80::B3FF:FFFF:8329', 93 | 'FE80::0202:B3FF:FFFF:8329' => 'FE80::0202:B3FF:FFFF:8329', 94 | 'FE80::0000:0202:B3FF:FFFF:8329' => 'FE80::0000:0202:B3FF:FFFF:8329', 95 | 'FE80::0000:0000:0202:B3FF:FFFF:8329' => 'FE80::0000:0000:0202:B3FF:FFFF:8329', 96 | 'FE80:0000:0000:0000:0202:B3FF:FFFF:8329' => 'FE80:0000:0000:0000:0202:B3FF:FFFF:8329', 97 | ]; 98 | 99 | foreach ($examples as $ip => $expected) { 100 | $result = Regex::ipv6($ip); 101 | 102 | $this->assertSame($expected, $result); 103 | } 104 | } 105 | 106 | #[DataProvider('providesMatchSubjects')] 107 | public function test_matches( 108 | $method, 109 | $subject, 110 | $allowWhitespace, 111 | $expected 112 | ) { 113 | $result = Regex::{$method}($subject, $allowWhitespace); 114 | 115 | $this->assertSame($expected, $result); 116 | } 117 | 118 | public static function providesMatchSubjects() 119 | { 120 | $allowWhitespace = true; 121 | $disallowWhitespace = false; 122 | 123 | $valid = true; 124 | $invalid = false; 125 | 126 | return [ 127 | 128 | 'match alpha' => [ 129 | 'isAlpha', 130 | 'AbČdë', 131 | $disallowWhitespace, 132 | $valid, 133 | ], 134 | 135 | 'match alpha allow whitespace' => [ 136 | 'isAlpha', 137 | 'AbČd ë', 138 | $allowWhitespace, 139 | $valid, 140 | ], 141 | 142 | 'match alpha disallow whitespace' => [ 143 | 'isAlpha', 144 | 'AbČd ë', 145 | $disallowWhitespace, 146 | $invalid, 147 | ], 148 | 149 | 'match non alpha' => [ 150 | 'isAlpha', 151 | 'AbČdë2.', 152 | $disallowWhitespace, 153 | $invalid, 154 | ], 155 | 156 | 'match alphadash' => [ 157 | 'isAlphadash', 158 | 'AbČdë2_-', 159 | $disallowWhitespace, 160 | $valid, 161 | ], 162 | 163 | 'match alphadash allow whitespace' => [ 164 | 'isAlphadash', 165 | 'AbČd ë2_-', 166 | $allowWhitespace, 167 | $valid, 168 | ], 169 | 170 | 'match alphadash disallow whitespace' => [ 171 | 'isAlphadash', 172 | 'AbČd ë2_-', 173 | $disallowWhitespace, 174 | $invalid, 175 | ], 176 | 177 | 'match non alphadash' => [ 178 | 'isAlphadash', 179 | 'AbČdë2_-!', 180 | $disallowWhitespace, 181 | $invalid, 182 | ], 183 | 184 | 'match alphanumeric' => [ 185 | 'isAlphanumeric', 186 | 'AbČdë2', 187 | $disallowWhitespace, 188 | $valid, 189 | ], 190 | 191 | 'match alphanumeric allow whitespace' => [ 192 | 'isAlphanumeric', 193 | 'AbČdë 2', 194 | $allowWhitespace, 195 | $valid, 196 | ], 197 | 198 | 'match alphanumeric disallow whitespace' => [ 199 | 'isAlphanumeric', 200 | 'AbČdë 2', 201 | $disallowWhitespace, 202 | $invalid, 203 | ], 204 | 205 | 'match non alphanumeric' => [ 206 | 'isAlphanumeric', 207 | 'AbČdë2-', 208 | $disallowWhitespace, 209 | $invalid, 210 | ], 211 | 212 | 'match digits' => [ 213 | 'isDigits', 214 | '12345', 215 | $disallowWhitespace, 216 | $valid, 217 | ], 218 | 219 | 'match digits allow whitespace' => [ 220 | 'isDigits', 221 | '1234 5', 222 | $allowWhitespace, 223 | $valid, 224 | ], 225 | 226 | 'match digits disallow whitespace' => [ 227 | 'isDigits', 228 | '1234 5', 229 | $disallowWhitespace, 230 | $invalid, 231 | ], 232 | 233 | 'match non digits' => [ 234 | 'isDigits', 235 | '12345A', 236 | $disallowWhitespace, 237 | $invalid, 238 | ], 239 | 240 | 'match numeric' => [ 241 | 'isNumeric', 242 | '-11.3456', 243 | $disallowWhitespace, 244 | $valid, 245 | ], 246 | 247 | 'match non numeric' => [ 248 | 'isNumeric', 249 | '10^4', 250 | $disallowWhitespace, 251 | $invalid, 252 | ], 253 | 254 | ]; 255 | } 256 | 257 | public function test_uuid_match() 258 | { 259 | $expected = '440526d4-04bd-43c4-9ac5-55e15c835d0d'; 260 | 261 | $result = Regex::isUuid('440526d4-04bd-43c4-9ac5-55e15c835d0d'); 262 | 263 | $this->assertTrue($result); 264 | 265 | $result = Regex::isUuid('4405 26d4-04bd43c4-9ac5 - 55e15c 835d0d '); 266 | 267 | $this->assertFalse($result); 268 | } 269 | 270 | public function test_ipv4_match() 271 | { 272 | $examples = [ 273 | '192.168.1.1' => true, 274 | '127.0.0.1' => true, 275 | '0.0.0.0' => true, 276 | '255.255.255.255' => true, 277 | '256.256.256.256' => false, 278 | '999.999.999.999' => false, 279 | '1.2.3' => false, 280 | '1.2.3.4' => true, 281 | ]; 282 | 283 | foreach ($examples as $ip => $expected) { 284 | $ipResult = Regex::isIp($ip); 285 | $ipv4Result = Regex::isIpv4($ip); 286 | 287 | $this->assertSame($expected, $ipResult); 288 | $this->assertSame($expected, $ipv4Result); 289 | } 290 | } 291 | 292 | public function test_ipv6_match() 293 | { 294 | $examples = [ 295 | '2001:0db8:85a3:0000:0000:8a2e:0370:7334' => true, 296 | 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329' => true, 297 | '192.168.1.1' => false, 298 | 'test:test:test:test:test:test:test:test' => false, 299 | ]; 300 | 301 | foreach ($examples as $ip => $expected) { 302 | $result = Regex::isIpv6($ip); 303 | 304 | $this->assertSame($expected, $result); 305 | } 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 |