Passed
Push — master ( 2d63f5...f4d34a )
by Korotkov
13:30 queued 11:37
created

MySQL   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A writeLog() 0 8 1
A isTable() 0 7 1
A __construct() 0 1 1
1
<?php
2
3
namespace App\Ship\Utils\Database\Driver;
4
5
use Rudra\Container\Facades\Rudra;
6
7
class MySQL
8
{
9
    public function __construct(protected $table){}
10
11
    public function isTable()
12
    {
13
        $query = Rudra::get("DSN")->query("
14
            SHOW TABLES LIKE '{$this->table}';
15
        ");
16
17
        return $query->fetchColumn();
18
    }
19
20
    public function writeLog(string $name): void
21
    {
22
        $query = Rudra::get("DSN")->prepare("
23
            INSERT INTO {$this->table} (`name`)
24
            VALUES (:name)"
25
        );
26
27
        $query->execute([':name' => $name]);
28
    }
29
}
30