Passed
Push — main ( 8db6c4...70b583 )
by Osvaldo
01:45
created

Vista::ver()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 6
nop 2
dl 0
loc 14
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace app\librerias\vista;
4
5
use app\librerias\vista\UtilidadesParaVistas;
6
7
use const VISTAS_DIR;
8
9
class Vista extends UtilidadesParaVistas
10
{
11
    private $_datos;
12
13
    public function ver(array $array, $datos = []): void
14
    {
15
        $vistas = count($array);
16
        $x = 0;
17
18
        foreach ($array as $value) {
19
            if ($this->laVistaExiste($value)) {
20
                $x++;
21
            }
22
        }
23
24
        if ($x == $vistas) {
25
            $this->_datos = (object) $datos;
26
            $this->requerirTodasLasVistas($array);
27
        }
28
    }
29
30
    private function laVistaExiste(string $vista): bool
31
    {
32
        return file_exists(VISTAS_DIR.$vista.'.php');
33
    }
34
35
    private function requerirTodasLasVistas(array $array): void
36
    {
37
        foreach ($array as $vista) {
38
            require_once VISTAS_DIR. $vista.'.php';
39
        }
40
    }
41
}
42