Test Failed
Pull Request — stable (#73)
by Nuno
04:10
created

Configurations::getDetectedConfigs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace LaravelZero\Framework\Bootstrappers;
4
5
use LaravelZero\Framework\Commands;
6
7
/**
8
 * This is the Laravel Zero Framework Bootstrapper Configuration class.
9
 *
10
 * Configures the console application.
11
 *
12
 * Takes in consideration the app name and the app version. Also
13
 * adds all the application commands.
14
 *
15
 * @author Nuno Maduro <[email protected]>
16
 */
17
class Configurations extends Bootstrapper
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function bootstrap(): void
23
    {
24
        $config = $this->container->make('config');
25
26
        foreach ($this->getDetectedConfigs() as $configFile) {
27
            $configFilename = pathinfo($configFile)['filename'];
28
29
            $config->set($configFilename, require $configFile);
30
        }
31
32
        if ($name = $config->get('app.name')) {
33
            $this->application->setName($name);
34
        }
35
36
        if ($version = $config->get('app.version')) {
37
            $this->application->setVersion($version);
38
        }
39
    }
40
41
    /**
42
     * Returns detected configs.
43
     *
44
     * @return array
45
     */
46
    protected function getDetectedConfigs(): array
47
    {
48
        $configPath = config_path();
49
50
        return glob("$configPath/*.php");
51
    }
52
}
53