Issues (4)

src/CorsServiceProvider.php (1 issue)

Labels
Severity
1
<?php namespace Nord\Lumen\Cors;
2
3
use Illuminate\Support\ServiceProvider;
4
use Nord\Lumen\Cors\Contracts\CorsService as CorsServiceContract;
5
6
class CorsServiceProvider extends ServiceProvider
7
{
8
    const CONFIG_KEY = 'cors';
9
10
    /**
11
     * @inheritdoc
12
     */
13
    public function register(): void
14
    {
15
        // In Lumen application configuration files needs to be loaded implicitly
16
        if ($this->app instanceof \Laravel\Lumen\Application) {
17
            $this->app->configure(self::CONFIG_KEY);
18
        } else {
19
            $this->publishes([$this->configPath() => config_path('cors.php')]);
0 ignored issues
show
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

19
            $this->publishes([$this->configPath() => /** @scrutinizer ignore-call */ config_path('cors.php')]);
Loading history...
20
        }
21
22
        $this->registerBindings();
23
    }
24
25
26
    /**
27
     * Registers container bindings.
28
     */
29
    protected function registerBindings(): void
30
    {
31
        // TODO: Change to bind the implementation to the interface instead.
32
        $this->app->bind(CorsService::class, function () {
33
            return new CorsService(config(self::CONFIG_KEY));
34
        });
35
36
        $this->app->alias(CorsService::class, CorsServiceContract::class);
37
    }
38
39
    /**
40
     * Default config file path
41
     *
42
     * @return string
43
     */
44
    protected function configPath(): string
45
    {
46
        return __DIR__ . '/../config/cors.php';
47
    }
48
}
49