GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 91ba9f...2f39ea )
by Lanre
15:30
created

functions.php ➔ toKobo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Gbowo;
4
5
if (!function_exists("Gbowo\\env")) {
6
    /**
7
     * * Load a value from `$_ENV`.
8
     * @param string $value
9
     * @return mixed
10
     */
11
    function env(string $value)
0 ignored issues
show
Coding Style introduced by
env uses the super-global variable $_ENV which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
12
    {
13 26
        return $_ENV[$value];
14
    }
15
}
16
17
if (!function_exists("Gbowo\\generateTransRef")) {
18
    /**
19
     * Generate a cryptographically secure random string
20
     * @param int $length Defaults to 10
21
     * @return string
22
     */
23
    function generateTransRef(int $length = 10)
24
    {
25 5
        return bin2hex(random_bytes($length));
26
    }
27
}
28
29
if (!function_exists("Gbowo\\toKobo")) {
30
    /**
31
     * Convert a given amount to it's kobo equivalent.
32
     * This is just an helper function and you def' can do without it
33
     * @param  $amount
34
     * @return float
35
     */
36
    function toKobo($amount)
37
    {
38 2
        return $amount * 100;
39
    }
40
}
41