Passed
Push — master ( cc0804...5222f0 )
by Scrutinizer
01:15
created

ConfigStaticMethods::isAlphaNumeric()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the keinos/mastodon-streaming-api-config package.
5
 *
6
 * - Authors, copyright, license, usage and etc.:
7
 *   - See: https://github.com/KEINOS/Mastodon_StreamingAPI_Config/
8
 */
9
10
declare(strict_types=1);
11
12
namespace KEINOS\MSTDN_TOOLS;
13
14
/**
15
 * Parent class of \KEINOS\MSTDN_TOOLS\ConfigProtectedMethods Class.
16
 *
17
 * This class only contains static methods.
18
 */
19
class ConfigStaticMethods extends ConfigConstants
20
{
21
    /**
22
     * Checks if the URL protocol is "http:".
23
     *
24
     * @param  string $url
25
     * @return bool
26
     */
27
    public static function isUrlProtocolHttp(string $url): bool
28
    {
29
        $target = 'http:';
30
31
        return ($target === substr($url, 0, strlen($target)));
32
    }
33
34
    public static function isAlphaNumeric(string $string): bool
35
    {
36
        // Some server doesn't enable ctype_alnum by default
37
        //return ctype_alnum($string);
38
39
        return (preg_match('/^[a-zA-Z0-9]+$/', $string) > 0);
40
    }
41
}
42