Completed
Push — master ( 95b8e4...b19727 )
by Dmitry
06:52
created

src/Provider/ClickhouseProvider.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Basis\Provider;
4
5
use Basis\Clickhouse;
6
use Basis\Config;
7
use Basis\Service;
8
use ClickHouseDB\Client;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
11
class ClickhouseProvider extends AbstractServiceProvider
12
{
13
    protected $provides = [
14
        Client::class,
15
    ];
16
17
    public function register()
18
    {
19 3
        $this->getContainer()->share(Clickhouse::class, function () {
20 2
            return new Clickhouse($this->getContainer());
0 ignored issues
show
$this->getContainer() of type object<League\Container\ContainerInterface> is not a sub-type of object<Basis\Application>. It seems like you assume a concrete implementation of the interface League\Container\ContainerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
21 3
        });
22
23 3
        $this->getContainer()->share(Client::class, function () {
24 3
            $serviceName = $this->getContainer()->get(Service::class)->getName();
25 3
            $config = $this->getContainer()->get(Config::class)['clickhouse'];
26
27 3
            $clickhouse = new Client($config);
28 3
            $clickhouse->write('create database if not exists '.$serviceName);
29 3
            $clickhouse->database($serviceName);
30
31 3
            return $clickhouse;
32 3
        });
33 3
    }
34
}
35