Test Failed
Pull Request — master (#33)
by Serhii
04:22 queued 46s
created

ElasticSearchServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Matchish\ScoutElasticSearch;
6
7
use Elasticsearch\Client;
8
use Elasticsearch\ClientBuilder;
9
use Illuminate\Support\ServiceProvider;
10
11
final class ElasticSearchServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function register(): void
17
    {
18
        $this->app->bind(Client::class, function () {
19
            return ClientBuilder::create()->setHosts([config('elasticsearch.host')])->build();
20
        });
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function boot(): void
27
    {
28
        $this->publishes([
29
            __DIR__.'/../config/elasticsearch.php' => config_path('elasticsearch.php'),
30
        ], 'config');
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function provides(): array
37
    {
38
        return [Client::class];
39
    }
40
}
41