Completed
Push — stable ( 86ecc3...3a45ea )
by Nuno
07:34
created

LoadConfiguration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 51
ccs 20
cts 20
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 15 1
A getConfigurationFiles() 0 20 2
1
<?php
2
3
/**
4
 * This file is part of Laravel Zero.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace LaravelZero\Framework\Bootstrap;
13
14
use Symfony\Component\Finder\Finder;
15
use Illuminate\Console\Application as Artisan;
16
use Illuminate\Contracts\Foundation\Application;
17
use Illuminate\Foundation\Bootstrap\LoadConfiguration as BaseLoadConfiguration;
18
19
/**
20
 * This is the Laravel Zero Framework Bootstrap Load Configuration implementation.
21
 */
22
class LoadConfiguration extends BaseLoadConfiguration
23
{
24
    /**
25
     * Bootstrap configurations.
26
     *
27
     * @param \Illuminate\Contracts\Foundation\Application $app
28
     */
29 21
    public function bootstrap(Application $app): void
30
    {
31 21
        parent::bootstrap($app);
32
33
        /*
34
         * When artisan starts, sets the application name
35
         * and the application version.
36
         */
37 21
        Artisan::starting(
38 21
            function ($artisan) use ($app) {
39 21
                $artisan->setName($app['config']->get('app.name', 'Laravel Zero'));
40 21
                $artisan->setVersion($app->version());
41 21
            }
42
        );
43 21
    }
44
45
    /**
46
     * Get all of the configuration files for the application.
47
     *
48
     * @param  \Illuminate\Contracts\Foundation\Application $app
49
     *
50
     * @return array
51
     */
52 21
    protected function getConfigurationFiles(Application $app): array
53
    {
54 21
        $files = [];
55
56 21
        $configPath = $app->configPath();
57
58 21
        $configFiles = Finder::create()
59 21
            ->files()
60 21
            ->name('*.php')
61 21
            ->in($configPath);
62
63 21
        foreach ($configFiles as $file) {
64 21
            $directory = $this->getNestedDirectory($file, $configPath);
65 21
            $files[$directory . basename($file->getPathName(), '.php')] = $file->getPathName();
66
        }
67
68 21
        ksort($files, SORT_NATURAL);
69
70 21
        return $files;
71
    }
72
}
73