Completed
Push — develop ( a66f64...08fdc8 )
by Josef
02:00
created

Helper::buildQueryString()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17
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 17
rs 9.2
cc 4
eloc 9
nc 6
nop 1
1
<?php
2
3
namespace ritero\SDK\TwitchTV;
4
5
/**
6
 * TwitchException for TwitchTV API SDK for PHP
7
 *
8
 * PHP SDK for interacting with the TwitchTV API
9
 *
10
 * @author Josef Ohnheiser <[email protected]>
11
 * @license https://github.com/jofner/Twitch-SDK/blob/master/LICENSE.md MIT
12
 * @homepage https://github.com/jofner/Twitch-SDK
13
 */
14
class Helper
15
{
16
    /**
17
     * Build query string
18
     * @param $params
19
     * @return null|string
20
     */
21
    public function buildQueryString($params)
22
    {
23
        $param = array();
24
        $queryString = null;
25
26
        foreach ($params as $key => $value) {
27
            if (!empty($value)) {
28
                $param[$key] = $value;
29
            }
30
        }
31
32
        if (count($param) > 0) {
33
            $queryString = '?' . http_build_query($param);
34
        }
35
36
        return $queryString;
37
    }
38
}
39