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.

AbstractMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 39
c 2
b 0
f 0
dl 0
loc 113
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ mappingReferenceModel() 0 25 4
A mappingCurrentModel() 0 13 3
mappingReferenceModel() 0 25 ?
1
<?php
2
/**
3
 * This file is part of the O2System Reactor 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\Sql\Relations\Maps\Abstracts;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Reactor\Models\Sql\Model;
19
20
/**
21
 * Class AbstractMap
22
 * @package O2System\Reactor\Models\Sql\Relations\Maps\Abstracts
23
 */
24
abstract class AbstractMap
25
{
26
    /**
27
     * AbstractMap::$currentModel
28
     * 
29
     * @var Model
30
     */
31
    public $currentModel;
32
33
    /**
34
     * AbstractMap::$currentTable
35
     *
36
     * @var string
37
     */
38
    public $currentTable;
39
40
    /**
41
     * AbstractMap::$currentPrimaryKey
42
     *
43
     * @var string
44
     */
45
    public $currentPrimaryKey;
46
47
    /**
48
     * AbstractMap::$currentForeignKey
49
     *
50
     * @var string
51
     */
52
    public $currentForeignKey;
53
54
    /**
55
     * AbstractMap::$referenceModel
56
     *
57
     * @var Model
58
     */
59
    public $referenceModel;
60
61
    /**
62
     * AbstractMap::$referenceTable
63
     *
64
     * @var string
65
     */
66
    public $referenceTable;
67
68
    /**
69
     * AbstractMap::$referencePrimaryKey
70
     *
71
     * @var string
72
     */
73
    public $referencePrimaryKey;
74
75
    /**
76
     * AbstractMap::$referenceForeignKey
77
     *
78
     * @var string
79
     */
80
    public $referenceForeignKey;
81
82
    // ------------------------------------------------------------------------
83
84
    /**
85
     * AbstractMap::mappingCurrentModel
86
     *
87
     * @param string|Model $currentModel
88
     */
89
    protected function mappingCurrentModel($currentModel)
90
    {
91
        if ($currentModel instanceof Model) {
92
            $this->currentModel = $currentModel;
93
            $this->currentTable = $this->currentModel->table;
94
            $this->currentPrimaryKey = $this->currentModel->primaryKey;
95
        } elseif (class_exists($currentModel)) {
96
            $this->currentModel = models($currentModel);
97
            $this->currentTable = $this->currentModel->table;
98
            $this->currentPrimaryKey = $this->currentModel->primaryKey;
99
        } else {
100
            $this->currentTable = $currentModel;
101
            $this->currentPrimaryKey = 'id';
102
        }
103
    }
104
105
    // ------------------------------------------------------------------------
106
107
    /**
108
     * AbstractMap::mappingReferenceModel
109
     *
110
     * @param string|Model $referenceModel
111
     */
112
    protected function mappingReferenceModel($referenceModel)
113
    {
114
        if ($referenceModel instanceof Model) {
115
            $this->referenceModel = $referenceModel;
116
            $this->referenceTable = $this->referenceModel->table;
117
            $this->referencePrimaryKey = $this->referenceModel->primaryKey;
118
        } elseif (class_exists($referenceModel)) {
119
            $this->referenceModel = models($referenceModel);
120
            $this->referenceTable = $this->referenceModel->table;
121
            $this->referencePrimaryKey = $this->referenceModel->primaryKey;
122
        } else {
123
            $this->referenceModel = new class extends Model
124
            {
125
            };
126
            $this->referenceModel->table = $this->referenceTable = $referenceModel;
127
            $this->referenceModel->primaryKey = $this->referencePrimaryKey = 'id';
128
        }
129
130
        if (empty($this->currentForeignKey)) {
131
            $this->currentForeignKey = $this->referencePrimaryKey . '_' . str_replace([
132
                    't_',
133
                    'tm_',
134
                    'tr_',
135
                    'tb_',
136
                ], '', $this->referenceTable);
137
        }
138
    }
139
}