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

bindFilenameFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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