Passed
Push — main ( 5b1d24...0bc9e7 )
by Osvaldo
01:39
created

Update   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 14 2
A __construct() 0 10 1
1
<?php
2
namespace src\pdoDataBase\update;
3
4
use src\pdoDataBase\select\{
5
    Tabla,
6
    Donde
7
};
8
9
use src\pdoDataBase\insert\ValoresAInsertar;
10
11
class Update
12
{
13
    private $_tabla;
14
    private $_donde;
15
    private $_valoresAInsertar;
16
17
    public function __construct
18
    (
19
        Tabla $Tabla,
20
        Donde $Donde,
21
        ValoresAInsertar $ValoresAInsertar
22
    )
23
    {
24
        $this->_tabla = $Tabla;
25
        $this->_donde = $Donde;
26
        $this->_valoresAInsertar = $ValoresAInsertar;
27
    }
28
29
    public function update(): string
30
    {
31
        $set = "";
32
		$values = [];
33
34
		foreach ($this->_valoresAInsertar->valoresAInsertar() as $key => $value)
35
		{
36
			$set = $set. ' ' .$key. ' = ?,';
37
			array_push($values, $value);
38
		}
39
40
        $valores = trim($set, ',');
41
42
        return "UPDATE " . $this->_tabla->tabla(). " SET ".$valores.$this->_donde->donde();
43
    }
44
}