Completed
Push — master ( 8e9456...c023b7 )
by Rigel Kent
01:22
created

TextToSpeechServiceProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 72
c 0
b 0
f 0
wmc 7
lcom 1
cbo 3
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 2
A register() 0 10 1
A registerTextToSpeechManager() 0 6 1
A registerAliases() 0 4 1
A bindFilenameFormatter() 0 4 1
A provides() 0 6 1
1
<?php
2
3
namespace Cion\TextToSpeech\Providers;
4
5
use Cion\TextToSpeech\Contracts\Formatter;
6
use Cion\TextToSpeech\Facades\TextToSpeech;
7
use Cion\TextToSpeech\Formatters\DefaultFilenameFormatter;
8
use Cion\TextToSpeech\TextToSpeechManager;
9
use Illuminate\Support\ServiceProvider;
10
11
class TextToSpeechServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16
    public function boot()
17
    {
18
        if ($this->app->runningInConsole()) {
19
            $this->publishes([
20
                __DIR__.'/../../config/config.php' => config_path('tts.php'),
21
            ], 'config');
22
        }
23
    }
24
25
    /**
26
     * Register the application services.
27
     */
28
    public function register()
29
    {
30
        $this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'tts');
31
32
        $this->registerTextToSpeechManager();
33
34
        $this->registerAliases();
35
36
        $this->bindFilenameFormatter();
37
    }
38
39
    /**
40
     * Registers the Text to speech manager.
41
     *
42
     * @return void
43
     */
44
    protected function registerTextToSpeechManager()
45
    {
46
        $this->app->singleton('tts', function ($app) {
47
            return new TextToSpeechManager($app);
48
        });
49
    }
50
51
    /**
52
     * Register aliases.
53
     *
54
     * @return void
55
     */
56
    protected function registerAliases()
57
    {
58
        $this->app->alias(TextToSpeech::class, 'TTS');
59
    }
60
61
    /**
62
     * Binds the filename formatter.
63
     *
64
     * @return void
65
     */
66
    protected function bindFilenameFormatter()
67
    {
68
        $this->app->bind(Formatter::class, config('tts.audio.formatter'));
69
    }
70
71
    /**
72
     * Get the services provided by the provider.
73
     *
74
     * @return array
75
     */
76
    public function provides()
77
    {
78
        return [
79
            'tts',
80
        ];
81
    }
82
}
83