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 ( 05f062...75f675 )
by Julien
01:43
created

EnvFileWriter::append()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 8.8571
cc 6
eloc 8
nc 4
nop 3
crap 6
1
<?php
2
/**
3
 * Laravel-Env-Sync
4
 *
5
 * @author Julien Tant - Craftyx <[email protected]>
6
 */
7
8
namespace Jtant\LaravelEnvSync\Writer\File;
9
10
use Jtant\LaravelEnvSync\Writer\WriterInterface;
11
12
class EnvFileWriter implements WriterInterface
13
{
14
    /**
15
     * Append a new par of key/value to an env resource
16
     *
17
     * @param string|null $resource resource where is located the env content
18
     */
19 3
    public function append($resource, $key, $value)
20
    {
21 3
        $lastChar = substr(file_get_contents($resource), -1);
22
23 3
        $prefix = "";
24 3
        if ($lastChar != "\n" && $lastChar != "\r" && strlen($lastChar) == 1) {
25 3
            $prefix = PHP_EOL;
26
        }
27
28 3
        if (strpos($value, ' ') !== false && strpos($value, '"') === false) {
29 1
            $value = '"' . $value . '"';
30
        }
31
32 3
        file_put_contents($resource, $prefix . $key . '=' . $value, FILE_APPEND);
33 3
    }
34
}
35