Completed
Pull Request — master (#1)
by Arthur
02:19
created

TextSearchHandler::handle()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
rs 9.4285
cc 3
eloc 9
nc 4
nop 1
1
<?php
2
3
namespace Arthem\GoogleApi\Domain\Place\Query\Search;
4
5
use Arthem\GoogleApi\Domain\Place\Query\AbstractHandler;
6
use Arthem\GoogleApi\Domain\Place\VO\PlaceCollection;
7
8
class TextSearchHandler extends AbstractHandler
9
{
10
    /**
11
     * @param TextSearchQuery $query
12
     *
13
     * @return PlaceCollection
14
     */
15
    public function handle(TextSearchQuery $query)
16
    {
17
        $location = $query->getLocation();
18
19
        $params = [
20
            'query' => $query->getQuery()->getQuery(),
21
        ];
22
23
        if (null !== $location) {
24
            $params['location'] = $location->getLatitude().','.$location->getLongitude();
25
        }
26
27
        if (null !== $query->getRadius()) {
28
            $params['radius'] = $query->getRadius()->getRadius();
29
        }
30
31
        return $this->client->textsearch($params);
32
    }
33
}
34