Passed
Pull Request — master (#165)
by Anton
03:20
created

Model   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConnectionName() 0 3 1
A getTable() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Laravel Love.
5
 *
6
 * (c) Anton Komarev <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cog\Laravel\Love\Support\Database\Eloquent;
15
16
use Illuminate\Database\Eloquent\Model as IlluminateModel;
17
use Illuminate\Support\Facades\Config;
18
19
abstract class Model extends IlluminateModel
20
{
21
    /**
22
     * Get the current connection name for the model.
23
     *
24
     * @return null|string
25
     */
26
    public function getConnectionName(): ?string
27
    {
28
        return Config::get('love.storage.database.connection');
29
    }
30
31
    public function getTable(): string
32
    {
33
        return Config::get("love.storage.database.tables.{$this->table}")
34
            ?? $this->table;
35
    }
36
}
37