Places::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 9
nc 1
nop 5
1
<?php
2
3
/**
4
 * This file is a part of nekland places api package
5
 *
6
 * (c) Nekland <[email protected]>
7
 *
8
 * For the full license, take a look to the LICENSE file
9
 * on the root directory of this project
10
 */
11
12
namespace Nekland\PlacesApi;
13
14
use Nekland\BaseApi\ApiFactory;
15
use Nekland\BaseApi\Http\Auth\AuthFactory;
16
use Nekland\BaseApi\Http\HttpClientFactory;
17
use Nekland\BaseApi\Transformer\TransformerInterface;
18
use Symfony\Component\EventDispatcher\EventDispatcher;
19
20
/**
21
 * Class Places
22
 *
23
 * @method \Nekland\PlacesApi\Api\Search getSearchApi()
24
 * @method \Nekland\PlacesApi\Api\Autocomplete getAutocompleteApi()
25
 * @method \Nekland\PlacesApi\Api\Places getPlacesApi()
26
 */
27
class Places extends ApiFactory
28
{
29
    /**
30
     * @var array
31
     */
32
    private $options = [
33
        'base_url' => 'https://maps.googleapis.com/maps/api/place/',
34
        'user_agent' => 'php-places-api (https://github.com/Nekland/PlacesApi)'
35
    ];
36
37
38
    public function __construct(
39
        array $options = [],
40
        HttpClientFactory $httpClientFactory = null,
41
        EventDispatcher $dispatcher = null,
42
        TransformerInterface $transformer = null,
43
        AuthFactory $authFactory = null
44
    ) {
45
        $this->options = array_merge($this->options, $options);
46
        parent::__construct(new HttpClientFactory($this->options));
47
        $this->getAuthFactory()->addNamespace('Nekland\PlacesApi\Http\Auth');
48
    }
49
50
    /**
51
     * Return array of namespaces where AbstractApi instance are localized
52
     *
53
     *
54
     * @return string[] Example: ['Nekland\BaseApi\Api']
55
     */
56
    protected function getApiNamespaces()
57
    {
58
        return ['Nekland\PlacesApi\Api'];
59
    }
60
}
61