Total Complexity | 3 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | Class Factory implements FactoryInterface |
||
8 | { |
||
9 | private $_clase; |
||
10 | |||
11 | public function crear(string $nombreDeLaClase, array $parametros): object |
||
12 | { |
||
13 | $this->_clase = $this->verificarSiExisteLaClase($nombreDeLaClase); |
||
14 | |||
15 | $this->_clase = new $this->_clase; |
||
16 | |||
17 | return $this->_clase->crear($parametros); |
||
18 | } |
||
19 | |||
20 | private function verificarSiExisteLaClase($nombreDeLaClase) |
||
21 | { |
||
22 | if(!class_exists($nombreDeLaClase)) |
||
23 | { |
||
24 | throw new Exception("La clase no existe", 1); |
||
25 | } |
||
26 | |||
27 | return $nombreDeLaClase; |
||
28 | } |
||
29 | } |