Passed
Push — master ( 9a172a...9c608c )
by Joe Nilson
03:46 queued 13s
created

EditSettings   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 15
c 1
b 1
f 1
dl 0
loc 24
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A execAfterAction() 0 22 5
1
<?php
2
/*
3
 * Copyright (C) 2023 Joe Nilson <[email protected]>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as
7
 * published by the Free Software Foundation, either version 3 of the
8
 * License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Lesser General Public License for more details.
14
 * You should have received a copy of the GNU Lesser General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace FacturaScripts\Plugins\fsRepublicaDominicana\Extension\Controller;
19
20
use Closure;
21
use FacturaScripts\Core\Base\DataBase;
0 ignored issues
show
Bug introduced by
The type FacturaScripts\Core\Base\DataBase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
23
class EditSettings
24
{
25
    public function execAfterAction(): Closure
26
    {
27
         return function($action) {
28
            //return $action;
29
            if ($action === 'fixfacturasprov') {
30
                $dataBase = new DataBase();
31
                $sqlType = " CONSTRAINT ";
32
                if (FS_DB_TYPE === 'MYSQL') {
0 ignored issues
show
Bug introduced by
The constant FacturaScripts\Plugins\f...n\Controller\FS_DB_TYPE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
33
                    $sqlType = " INDEX ";
34
                }
35
                $result = $dataBase->exec("ALTER TABLE FACTURASPROV DROP " . $sqlType .
36
                                                " IF EXISTS uniq_empresancf_facturasprov;");
37
                //Exec drop if exists index uniq_empresancf_facturasprov
38
                if ($result) {
39
                    self::toolBox()->i18nLog()->notice('success-drop-index-uniq_empresancf_facturasprov');
0 ignored issues
show
Bug introduced by
The method toolBox() does not exist on FacturaScripts\Plugins\f...Controller\EditSettings. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
                    self::/** @scrutinizer ignore-call */ 
40
                          toolBox()->i18nLog()->notice('success-drop-index-uniq_empresancf_facturasprov');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
                } else {
41
                    self::toolBox()->i18nLog()->warning('error-drop-index-uniq_empresancf_facturasprov');
42
                }
43
44
45
            } elseif ($action === 'fixfacturascli') {
46
                self::toolBox()->i18nLog()->notice('fixfacturascli');
47
            }
48
         };
49
    }
50
51
}