Passed
Push — master ( de2d84...14c1fc )
by Stephen
05:39 queued 02:58
created

alphabet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
use Illuminate\Support\Facades\Cache;
4
5
6
/**
7
 * Return the alphabet in array form
8
 *
9
 * @return array
10
 */
11
function alphabet(): array {
12
    return Cache::rememberForever('alphabet', function () {
13
        return range('A', 'Z');
14
    });
15
}
16
17
/**
18
 * Return the index of a letter in the alphabet
19
 *
20
 * @param int $index
21
 * @return string
22
 */
23
function alphabetIndex(int $index): string {
24
    return alphabet()[$index];
25
}
26
27
28
/**
29
 * Retrieve a class's short name (without namespace)
30
 *
31
 * @param $class
32
 * @param bool $short Full name or short name
33
 * @param string|null $default
34
 * @return string
35
 */
36
function getClassName($class, $short = false, string $default = null): string
37
{
38
    // Attempt to resolve the $class's name
39
    try {
40
        return (new ReflectionClass($class))->{$short ? 'getShortName' : 'getName'}();
41
    }
42
43
        // Return $default
44
    catch (ReflectionException $e) {
45
        return $default;
46
    }
47
}
48
49
50
/**
51
 * Determine if the Application is running in a 'production' environment
52
 *
53
 * @return bool
54
 */
55
function isProductionEnvironment(): bool
56
{
57
    return env('APP_ENV') == 'production';
58
}
59
60
61
/**
62
 * Determine if the Application is running in a 'development' environment
63
 *
64
 * @return bool
65
 */
66
function isDevelopmentEnvironment(): bool
67
{
68
    return env('APP_ENV') == 'development';
69
}
70