1 | <?php |
||
2 | |||
3 | namespace F72X; |
||
4 | |||
5 | use F72X\Exception\ConfigException; |
||
6 | |||
7 | class F72X { |
||
8 | |||
9 | private static $production; |
||
10 | private static $requiredConfigFields = [ |
||
11 | 'RUC', |
||
12 | 'RAZON_SOCIAL', |
||
13 | 'NOMBRE_COMERCIAL', |
||
14 | 'USUARIO_SOL', |
||
15 | 'CLAVE_SOL', |
||
16 | 'CODIGO_DOMICILIO_FISCAL', |
||
17 | 'RUTA_CERTIFICADO', |
||
18 | 'RUTA_REPOSITORIO' |
||
19 | ]; |
||
20 | |||
21 | /** |
||
22 | * |
||
23 | * @param boolean $config |
||
24 | * @param type $prodMode |
||
25 | */ |
||
26 | public static function init($config, $prodMode = false) { |
||
27 | self::$production = $prodMode; |
||
28 | self::validateConfig($config); |
||
29 | Company::setConfig($config); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
30 | } |
||
31 | |||
32 | public static function isProductionMode() { |
||
33 | return self::$production; |
||
34 | } |
||
35 | |||
36 | private static function validateConfig($config) { |
||
37 | foreach (self::$requiredConfigFields as $field) { |
||
38 | if (!isset($config[$field])) { |
||
39 | throw new ConfigException(sprintf('La propiedad %s es obligatoria, por favor revise su cofiguración!', $field)); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 | |||
44 | } |
||
45 |