Query::toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
/**
4
 * This file is part of Laravel Meetups.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace LaravelMeetups\Http\Client;
13
14
use LaravelMeetups\Contracts\Http\Client\Query as Contract;
15
use LaravelMeetups\Contracts\Http\Client\Strategy;
16
17
/**
18
 * Class Query.
19
 */
20
class Query implements Contract
21
{
22
    /**
23
     * Holds an instance of strategy.
24
     *
25
     * @var Strategy
26
     */
27
    private $strategy;
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function __construct(Strategy $strategy)
33
    {
34
        $this->strategy = $strategy;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function toString()
41
    {
42
        $stringQuery = $this->strategy->getUrl();
43
44
        if (!empty($params = $this->strategy->getParams())) {
45
            $stringQuery .= '?'.http_build_query($params);
46
        }
47
48
        return $stringQuery;
49
    }
50
}
51