MirzaServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 23
dl 0
loc 52
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 21 1
A register() 0 16 1
1
<?php
2
3
namespace yak0d3\mirza_yandex_translator;
4
5
use Blade;
0 ignored issues
show
Bug introduced by
The type Blade was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\ServiceProvider;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\ServiceProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class MirzaServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishes([
18
            __DIR__.'/../config/mirza.php' => config_path('mirza.php'),
0 ignored issues
show
Bug introduced by
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
            __DIR__.'/../config/mirza.php' => /** @scrutinizer ignore-call */ config_path('mirza.php'),
Loading history...
19
        ]);
20
        Blade::directive('translate', function ($expression) {
21
            $expression = explode(',', $expression);
22
            $text = $expression[0];
23
            $lang = $expression[1];
24
25
            return "<?php echo Mirza::translate($text, $lang); ?>";
26
        });
27
        Blade::directive('langselect', function () {
28
            return '<?php echo Mirza::languages_select(); ?>';
29
        });
30
        Blade::directive('yandex_rights', function ($expression) {
31
            $expression = explode(',', $expression);
32
            $color = $expression[0];
33
            $fontsize = $expression[1];
34
35
            return "<?php echo Mirza::yandex_rights($color,$fontsize); ?>";
36
        });
37
    }
38
39
    /**
40
     * Register services.
41
     *
42
     * @return void
43
     */
44
    public function register()
45
    {
46
        $this->mergeConfigFrom(
47
            __DIR__.'/../config/mirza.php', 'mirza'
48
        );
49
50
        \App::singleton('MirzaClient', function () {
51
            return new MirzaClient(config('mirza.secret'));
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
            return new MirzaClient(/** @scrutinizer ignore-call */ config('mirza.secret'));
Loading history...
52
        });
53
        \App::bind('Mirza', function () {
54
            $client = resolve('MirzaClient');
0 ignored issues
show
Bug introduced by
The function resolve was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

54
            $client = /** @scrutinizer ignore-call */ resolve('MirzaClient');
Loading history...
55
56
            return new Mirza($client);
57
        });
58
59
        \App::alias('Mirza', 'yak0d3\Mirza_Yandex_Translator\MirzaFacade');
60
    }
61
}
62