Query   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toString() 0 10 2
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