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

Update::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
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 3
dl 0
loc 10
rs 10
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
}