ParsedownServiceProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Yansongda\LaravelParsedown;
4
5
use Illuminate\Foundation\Application as LaravelApplication;
6
use Illuminate\Support\Facades\Blade;
7
use Illuminate\Support\ServiceProvider;
8
use Laravel\Lumen\Application as LumenApplication;
0 ignored issues
show
Bug introduced by
The type Laravel\Lumen\Application 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...
9
use Parsedown;
10
11
class ParsedownServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * delay to load service.
15
     *
16
     * @var bool
17
     */
18
    protected $defer = true;
19
20
    /**
21
     * boot a service.
22
     *
23
     * @author yansongda <[email protected]>
24
     *
25
     * @return void
26
     */
27
    public function boot()
28
    {
29
        if ($this->app instanceof LaravelApplication
30
            && $this->app->runningInConsole()
31
        ) {
32
            $this->publishes(
33
                [
34
                    __DIR__.'/config/markdown.php' => config_path('markdown.php'),
35
                ],
36
                'laravel-parsedown-config'
37
            );
38
        } elseif ($this->app instanceof LumenApplication) {
39
            $this->app->configure('markdown');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. Did you maybe mean configPath()? ( Ignorable by Annotation )

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

39
            $this->app->/** @scrutinizer ignore-call */ 
40
                        configure('markdown');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method configure() does not exist on Illuminate\Foundation\Application. Did you maybe mean configPath()? ( Ignorable by Annotation )

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

39
            $this->app->/** @scrutinizer ignore-call */ 
40
                        configure('markdown');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
        }
41
42
        Blade::directive('parsedown', function ($expression) {
43
            return "<?php echo parsedown($expression); ?>";
44
        });
45
    }
46
47
    /**
48
     * registe the service.
49
     *
50
     * @return void
51
     */
52
    public function register()
53
    {
54
        $this->mergeConfigFrom(dirname(__DIR__).'/config/markdown.php', 'markdown');
55
56
        $this->app->singleton(Parsedown::class, function () {
57
            return Parsedown::instance()->setSafeMode(config('markdown.parsedown.safeMode'))
58
                ->setBreaksEnabled(config('markdown.parsedown.breaksEnabled'))
59
                ->setMarkupEscaped(config('markdown.parsedown.markupEscaped'))
60
                ->setUrlsLinked(config('markdown.parsedown.urlsLinked'));
61
        });
62
63
        $this->app->alias(Parsedown::class, 'parsedown');
64
    }
65
66
    /**
67
     * providers.
68
     *
69
     * @return array
70
     */
71
    public function provides()
72
    {
73
        return [Parsedown::class, 'parsedown'];
74
    }
75
}
76