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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 35
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDiff() 0 13 1
A ensureFileExists() 0 8 3
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