-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReadsPackageConfig.php
More file actions
24 lines (21 loc) · 821 Bytes
/
Copy pathReadsPackageConfig.php
File metadata and controls
24 lines (21 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace PlinCode\KmlParser\Traits;
trait ReadsPackageConfig
{
/**
* Read a package config value, falling back when there is no application.
*
* The parser and the extractor are both useful outside a booted Laravel
* application: a console script, a plain PHPUnit test, a queue bootstrap
* that has not resolved the config repository yet. The config() helper
* does not degrade there, it throws BindingResolutionException, so the
* container is only consulted once something is actually bound to it.
*/
protected function packageConfig(string $key, mixed $default): mixed
{
if (! function_exists('config') || ! function_exists('app') || ! app()->bound('config')) {
return $default;
}
return config($key, $default);
}
}