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

MySQL::writeLog()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
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