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.

SyncService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Laravel-Env-Sync
4
 *
5
 * @author Julien Tant - Craftyx <[email protected]>
6
 */
7
8
namespace Jtant\LaravelEnvSync;
9
10
use Jtant\LaravelEnvSync\Reader\ReaderInterface;
11
12
class SyncService
13
{
14
    /**
15
     * @var ReaderInterface
16
     */
17
    private $reader;
18
19 9
    public function __construct(ReaderInterface $reader)
20
    {
21 9
        $this->reader = $reader;
22 9
    }
23
24 8
    public function getDiff($source, $destination)
25
    {
26 8
        $this->ensureFileExists($source, $destination);
27
28 7
        $destinationValues = $this->reader->read($destination);
29 7
        $sourceValues = $this->reader->read($source);
30
31 7
        $diffKeys = array_diff(array_keys($sourceValues), array_keys($destinationValues));
32
33 7
        return array_filter($sourceValues, function ($key) use ($diffKeys) {
34 7
            return in_array($key, $diffKeys);
35 7
        }, ARRAY_FILTER_USE_KEY);
36
    }
37
38 8
    private function ensureFileExists(...$files)
39
    {
40 8
        foreach ($files as $file) {
41 8
            if (!file_exists($file)) {
42 8
                throw new FileNotFound(sprintf("%s must exists", $file));
43
            }
44
        }
45 7
    }
46
}
47