Passed
Push — master ( 1156a5...423021 )
by guilherme
01:25
created

Delete   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 18
c 0
b 0
f 0
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getResult() 0 3 1
A delete() 0 16 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Usuario
5
 * Date: 05/02/2020
6
 * Time: 21:44
7
 */
8
9
namespace database;
10
11
12
class Delete
13
{
14
15
    private $table;
16
    private $terms;
17
    private $delete;
18
    private $statements;
19
    private $result;
20
    private $error;
21
22
23
    public function __construct()
24
    {
25
    }
26
27
    /**
28
     * @return mixed
29
     */
30
    public function getResult()
31
    {
32
        return $this->result;
33
    }
34
35
36
37
    public function delete(string $table, string $terms, string $parseString)
38
    {
39
        $this->table = $table;
40
        $this->terms = $terms;
41
42
        parse_str($parseString, $this->statements);
43
44
        $this->delete = "DELETE FROM {$this->table} {$this->terms}";
45
46
        try{
47
            $this->result = DB::connect()->prepare($this->delete);
48
            $this->result->execute($this->statements);
49
            $this->error = true;
50
51
        }catch (\PDOException $e){
52
            echo $e->getMessage();
53
54
        }
55
56
    }
57
58
}