GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ClientFactory::createClient()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 2
1
<?php
2
3
namespace Nimble\ElasticBundle\Client;
4
5
use Elasticsearch\Client;
6
use Elasticsearch\ClientBuilder;
7
use Pinkeen\ApiDebugBundle\Bridge\RingPHP\Service\RingPHPHandlerFactory;
8
use Psr\Log\LoggerInterface;
9
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
10
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
11
12
class ClientFactory implements ContainerAwareInterface
13
{
14
    use ContainerAwareTrait;
15
16
    /**
17
     * @param array $hosts
18
     * @param LoggerInterface $logger
19
     * @return Client
20
     */
21
    public function createClient(array $hosts, LoggerInterface $logger = null)
22
    {
23
        $builder =  ClientBuilder::create();
24
25
        $builder
26
            ->setHosts($hosts)
27
        ;
28
29
        if (null !== $logger) {
30
            $builder->setLogger($logger);
31
        }
32
33
        if ($this->container->has('ring_php.handler_factory')) {
34
            /** @var RingPHPHandlerFactory $handlerFactory */
35
            $handlerFactory = $this->container->get('ring_php.handler_factory');
36
            $builder->setHandler($handlerFactory->create(
37
                ClientBuilder::defaultHandler(),
38
                'elastic'
39
            ));
40
        }
41
42
        return $builder->build();
43
    }
44
}
45
46