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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 6
c 1
b 1
f 0
lcom 0
cbo 0
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B append() 0 15 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