ParsehtmlServiceProvider::boot()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 3
nop 0
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Yansongda\LaravelParsehtml;
4
5
use Illuminate\Foundation\Application as LaravelApplication;
0 ignored issues
show
Bug introduced by
The type Illuminate\Foundation\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...
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 League\HTMLToMarkdown\HtmlConverter;
10
11
class ParsehtmlServiceProvider 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 && $this->app->runningInConsole()) {
30
            $this->publishes([
31
                dirname(__DIR__).'/config/markdown.php' => config_path('markdown.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

31
                dirname(__DIR__).'/config/markdown.php' => /** @scrutinizer ignore-call */ config_path('markdown.php'),
Loading history...
32
            ], 'laravel-html-config');
33
        } elseif ($this->app instanceof LumenApplication) {
34
            $this->app->configure('markdown');
0 ignored issues
show
Bug introduced by
The method configure() does not exist on Illuminate\Contracts\Foundation\Application. ( Ignorable by Annotation )

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

34
            $this->app->/** @scrutinizer ignore-call */ 
35
                        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...
35
        }
36
37
        Blade::directive('parsehtml', function ($expression) {
38
            return "<?php echo parsehtml($expression); ?>";
39
        });
40
    }
41
42
    /**
43
     * registe the service.
44
     *
45
     * @return void
46
     */
47
    public function register()
48
    {
49
        $this->mergeConfigFrom(dirname(__DIR__).'/config/markdown.php', 'markdown');
50
51
        $this->app->singleton(HtmlConverter::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

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

51
        $this->app->singleton(HtmlConverter::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
            return new HtmlConverter(config('markdown.parsehtml'));
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

52
            return new HtmlConverter(/** @scrutinizer ignore-call */ config('markdown.parsehtml'));
Loading history...
53
        });
54
55
        $this->app->alias(HtmlConverter::class, 'parsehtml');
56
    }
57
58
    /**
59
     * providers.
60
     *
61
     * @return array
62
     */
63
    public function provides()
64
    {
65
        return [HtmlConverter::class, 'parsehtml'];
66
    }
67
}
68