Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
12 / 12
FormatterServiceProvider
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
12 / 12
 boot
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 register
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
11 / 11
1<?php
2
3namespace Qmp\Laravel\DictionaryFormatter\Providers;
4
5use Illuminate\Support\Collection;
6use Illuminate\Support\ServiceProvider;
7use Qmp\Laravel\DictionaryFormatter\DictionaryFormatter;
8
9class FormatterServiceProvider extends ServiceProvider
10{
11    /**
12     * Boot all the validation rules.
13     *
14     * @return void
15     */
16    public function boot()
17    {
18    }
19
20    /**
21     * Undocumented function
22     *
23     * @return void
24     */
25    public function register()
26    {
27        $this->mergeConfigFrom(
28            __DIR__ . '/../../config/formatters.php',
29            'formatters'
30        );
31
32        $allowed =  Collection::make(glob(__DIR__ . '/../Formatters/*.php'))->map(function ($formatter) {
33            return strtolower(pathinfo($formatter, PATHINFO_FILENAME));
34        })->toArray();
35
36        config(['formatters.custom' => $allowed]);
37
38        $this->app->singleton('dictionaryFormatter', function ($app) {
39            return new DictionaryFormatter(config('formatters.custom'), config('formatters.rules'));
40        });
41    }
42}