Completed
Push — master ( d34180...f031a6 )
by Elf
03:53
created

ServiceProvider::isLumen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
namespace ElfSundae\BearyChat\Laravel;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
7
8
class ServiceProvider extends LaravelServiceProvider
9
{
10
    /**
11
     * Indicates if loading of the provider is deferred.
12
     *
13
     * @var bool
14
     */
15
    protected $defer = true;
16
17
    /**
18
     * Register the service provider.
19
     *
20
     * @return void
21
     */
22 5
    public function register()
23
    {
24 5
        $this->mergeConfigFrom($from = __DIR__.'/../config/bearychat.php', 'bearychat');
25
26 5
        if ($this->app->runningInConsole()) {
27 5
            $to = (function_exists('config_path')) ? config_path('bearychat.php') : base_path('config/bearychat.php');
28 5
            $this->publishes([$from => $to], 'bearychat');
29
        }
30
31 5
        $this->app->singleton('bearychat', function ($app) {
32 5
            return (new ClientManager)
33 5
                ->setDefaultName($app['config']->get('bearychat.default'))
34 5
                ->setClientsDefaults($app['config']->get('bearychat.clients_defaults'))
35 5
                ->setClientsConfig($app['config']->get('bearychat.clients'));
36 5
        });
37
38 5
        $this->app->alias('bearychat', ClientManager::class);
39 5
    }
40
41
    /**
42
     * Detemines if the application is Lumen.
43
     *
44
     * @return bool
45
     */
46
    protected function isLumen()
47
    {
48
        return strpos($this->app->version(), 'Lumen') !== false;
49
    }
50
51
    /**
52
     * Get the services provided by the provider.
53
     *
54
     * @return string[]
55
     */
56 1
    public function provides()
57
    {
58 1
        return ['bearychat', ClientManager::class];
59
    }
60
}
61