Completed
Push — master ( c1abc1...1c17fb )
by Josef
03:52
created

Helper::buildQueryString()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 6
nop 1
1
<?php
2
3
namespace jofner\SDK\TwitchTV;
4
5
/**
6
 * Helper 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