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 ( 79e180...3094b9 )
by Miles
09:00
created

TransformerTrait::toEnv()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4286
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of the m1\vars library
5
 *
6
 * (c) m1 <[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
 * @package     m1/vars
12
 * @version     0.2.0
13
 * @author      Miles Croxford <[email protected]>
14
 * @copyright   Copyright (c) Miles Croxford <[email protected]>
15
 * @license     http://github.com/m1/vars/blob/master/LICENSE
16
 * @link        http://github.com/m1/vars/blob/master/README.MD Documentation
17
 */
18
19
namespace M1\Vars\Traits;
20
21
/**
22
 * Vars transformer class for to*() functions
23
 *
24
 * @since 0.2.0
25
 */
26
trait TransformerTrait
27
{
28
29
    /**
30
     * Makes it so the content is available in getenv()
31
     */
32 1
    public function toEnv(){
33 1
        $dots = $this->toDots($this->content);
0 ignored issues
show
Bug introduced by
The property content does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Unused Code introduced by
The call to TransformerTrait::toDots() has too many arguments starting with $this->content.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
35 1
        foreach ($dots as $dot_k => $dot_v) {
36 1
            putenv(sprintf('%s=%s', $dot_k, $dot_v));
37
38 1
        }
39 1
    }
40
41
    /**
42
     * Converts the array into a flat dot notation array
43
     *
44
     * @return array The dot notation array
45
     */
46 1
    public function toDots()
47
    {
48 1
        return $this->dotTransformer($this->content);
49
    }
50
51
    /**
52
     * Converts the array into a flat dot notation array
53
     *
54
     * @param array  $content The content array
55
     * @param string $prefix  The prefix for the key
56
     *
57
     * @return array The dot notation array
58
     */
59 1
    private function dotTransformer($content, $prefix = '')
60
    {
61 1
        $parsed = array();
62
63 1
        foreach ($content as $arr_k => $arr_v) {
64 1
            if (is_array($arr_v)) {
65 1
                $parsed = array_merge($parsed, $this->dotTransformer($arr_v, $prefix.$arr_k."."));
66 1
            } else {
67 1
                $parsed[$prefix.$arr_k] = $arr_v;
68
            }
69 1
        }
70
71 1
        return $parsed;
72
    }
73
74
}