TextToSpeechServiceProvider   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 81
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 4 1
A registerTextToSpeechManager() 0 4 1
A register() 0 11 1
A bindFilenameFormatter() 0 3 1
A boot() 0 6 2
A bindSource() 0 3 1
A registerAliases() 0 3 1
1
<?php
2
3
namespace Cion\TextToSpeech\Providers;
4
5
use Cion\TextToSpeech\Contracts\Formatter;
6
use Cion\TextToSpeech\Contracts\Source;
7
use Cion\TextToSpeech\Facades\TextToSpeech;
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
        $this->bindSource();
39
    }
40
41
    /**
42
     * Registers the Text to speech manager.
43
     *
44
     * @return void
45
     */
46
    protected function registerTextToSpeechManager()
47
    {
48
        $this->app->singleton('tts', function ($app) {
49
            return new TextToSpeechManager($app);
50
        });
51
    }
52
53
    /**
54
     * Register aliases.
55
     *
56
     * @return void
57
     */
58
    protected function registerAliases()
59
    {
60
        $this->app->alias(TextToSpeech::class, 'TTS');
61
    }
62
63
    /**
64
     * Binds the filename formatter.
65
     *
66
     * @return void
67
     */
68
    protected function bindFilenameFormatter()
69
    {
70
        $this->app->bind(Formatter::class, config('tts.audio.formatter'));
71
    }
72
73
    /**
74
     * Binds the default source.
75
     *
76
     * @return void
77
     */
78
    protected function bindSource()
79
    {
80
        $this->app->bind(Source::class, config('tts.sources.'.config('tts.default_source')));
81
    }
82
83
    /**
84
     * Get the services provided by the provider.
85
     *
86
     * @return array
87
     */
88
    public function provides()
89
    {
90
        return [
91
            'tts',
92
        ];
93
    }
94
}
95