Test Failed
Pull Request — master (#8)
by Serhii
03:22
created

ElasticSearchServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 22
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 3 1
A register() 0 9 1
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 33
    public function register(): void
17
    {
18
        $this->app->bind(Client::class, function () {
19 24
            return ClientBuilder::create()->setHosts([config('elasticsearch.host')])->build();
20 33
        });
21
22 33
        $this->publishes([
23 33
            __DIR__.'/../config/elasticsearch.php' => config_path('elasticsearch.php'),
24 33
        ], 'config');
25 33
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function provides(): array
31
    {
32
        return [Client::class];
33
    }
34
}
35