Passed
Push — main ( 991369...557f8c )
by Tan
02:36
created

generateUrlWithPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 4
dl 0
loc 6
rs 10
1
<?php
2
3
function generateUrlWithPath(string $urlKey, string $pathKey, string $defaultUrl, string $defaultPath): string
4
{
5
    $url = env($urlKey, $defaultUrl);
6
    $path = env($pathKey, $defaultPath);
7
8
    return $path ? "{$url}/{$path}" : $url;
0 ignored issues
show
introduced by
$path is of type PhpOption\T, thus it always evaluated to true.
Loading history...
9
}
10
11
return [
12
    'name' => 'BlogCore',
13
14
    'fe_path' => env('BLOG_FE_PATH', 'blog'),
15
    'fe_url' => env('BLOG_FE_URL', 'https://cslant.com'),
16
    'fe_url_with_path' => generateUrlWithPath('BLOG_FE_URL', 'BLOG_FE_PATH', 'https://cslant.com', 'blog'),
17
18
    'admin_path' => env('BLOG_ADMIN_PATH', 'admin/blog'),
19
    'admin_url' => env('BLOG_ADMIN_URL', 'https://cslant.com'),
20
    'admin_url_with_path' => generateUrlWithPath('BLOG_ADMIN_URL', 'BLOG_ADMIN_PATH', 'https://cslant.com', 'admin/blog'),
21
22
    'api_path' => env('BLOG_API_PATH', 'api/blog'),
23
    'api_url' => env('BLOG_API_URL', 'https://cslant.com'),
24
    'api_url_with_path' => generateUrlWithPath('BLOG_API_URL', 'BLOG_API_PATH', 'https://cslant.com', 'api/blog'),
25
26
    'laravel_domain' => env('LARAVEL_BLOG_DOMAIN', 'no-accept-domain'),
27
28
    'view_throttle_minutes' => env('BLOG_VIEW_THROTTLE_MINUTES', 60),
29
30
    'blog_api_default_rate_limit' => env('BLOG_API_DEFAULT_RATE_LIMIT', 50),
31
];
32