ResolvesDatabaseDriver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 30
ccs 2
cts 6
cp 0.3333
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A usingSQLite() 0 3 1
A usingMySQL() 0 3 1
A usingPostgres() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MichaelRubel\SqlFunctionRepository\Traits;
6
7
use Illuminate\Database\MySqlConnection;
8
use Illuminate\Database\PostgresConnection;
9
use Illuminate\Database\SQLiteConnection;
10
use Illuminate\Support\Facades\DB;
11
12
trait ResolvesDatabaseDriver
13
{
14
    /**
15
     * Determine whether the application is using the SQLite database driver.
16
     *
17
     * @return bool
18
     */
19 1
    public function usingSQLite(): bool
20
    {
21 1
        return DB::connection() instanceof SQLiteConnection;
22
    }
23
24
    /**
25
     * Determine whether the application is using the MySQL database driver.
26
     *
27
     * @return bool
28
     */
29
    public function usingMySQL(): bool
30
    {
31
        return DB::connection() instanceof MySqlConnection;
32
    }
33
34
    /**
35
     * Determine whether the application is using the Postgres database driver.
36
     *
37
     * @return bool
38
     */
39
    public function usingPostgres(): bool
40
    {
41
        return DB::connection() instanceof PostgresConnection;
42
    }
43
}
44