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.
Passed
Push — master ( 86dce3...98cf71 )
by Nur
02:40
created

Model   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 5
1
<?php
2
/**
3
 * This file is part of the O2System PHP Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Reactor\Models\Files;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Filesystem\Files\JsonFile;
19
use O2System\Filesystem\Files\XmlFile;
20
use O2System\Reactor\Models\Files\Traits\FinderTrait;
21
use O2System\Psr\Patterns\Structural\Repository\AbstractRepository;
22
23
/**
24
 * Class Model
25
 * @package O2System\Reactor\Models\Files
26
 */
27
class Model extends AbstractRepository
28
{
29
    use FinderTrait;
30
31
    public $file;
32
    public $result;
33
    public $primaryKey = 'id';
34
35
    public function __construct()
36
    {
37
        if ( ! empty($this->file)) {
38
            $extension = pathinfo($this->file, PATHINFO_EXTENSION);
39
40
            switch ($extension) {
41
                case 'json':
42
                    $jsonFile = new JsonFile($this->file);
43
                    $this->storage = $jsonFile->readFile()->getArrayCopy();
44
                    break;
45
                case 'xml':
46
                    $xmlFile = new XmlFile($this->file);
47
                    $this->storage = $xmlFile->readFile()->getArrayCopy();
48
                    break;
49
            }
50
51
            $first = reset($this->storage);
52
            if ( ! isset($first[ $this->primaryKey ])) {
53
                $keys = $first->getKeys();
54
                $this->primaryKey = reset($keys);
55
            }
56
        }
57
    }
58
}