getAuth()   A
last analyzed

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 0
dl 0
loc 10
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A logging.php$0 ➔ user() 0 3 1
A logging.php$0 ➔ role() 0 3 1
1
<?php
2
3
use Lagdo\DbAdmin\Admin;
4
use Lagdo\DbAdmin\Config;
5
use Lagdo\DbAdmin\Db;
6
use Lagdo\DbAdmin\Driver;
7
use Lagdo\DbAdmin\Service;
8
use Lagdo\DbAdmin\Ui;
9
10
use function Jaxon\jaxon;
11
12
function getAuth(): Config\AuthInterface
13
{
14
    return new class implements Config\AuthInterface {
15
        public function user(): string
16
        {
17
            return '';
18
        }
19
        public function role(): string
20
        {
21
            return '';
22
        }
23
    };
24
}
25
26
return [
27
    'metadata' => [
28
        'format' => 'attributes',
29
    ],
30
    'directories' => [
31
        [
32
            'path' => __DIR__ . '/../app/ajax/Log',
33
            'namespace' => 'Lagdo\\DbAdmin\\Ajax\\Log',
34
            'autoload' => false,
35
        ],
36
    ],
37
    'views' => [
38
        'dbadmin::codes' => [
39
            'directory' => __DIR__ . '/../templates/codes',
40
            'extension' => '',
41
            'renderer' => 'jaxon',
42
        ],
43
        'dbadmin::views' => [
44
            'directory' => __DIR__ . '/../templates/views',
45
            'extension' => '.php',
46
            'renderer' => 'jaxon',
47
        ],
48
        'dbadmin::templates' => [
49
            'directory' => __DIR__ . '/../templates/views',
50
            'extension' => '.php',
51
            'renderer' => 'jaxon',
52
        ],
53
        'pagination' => [
54
            'directory' => __DIR__ . '/../templates/pagination',
55
            'extension' => '.php',
56
            'renderer' => 'jaxon',
57
        ],
58
    ],
59
    'container' => [
60
        'set' => [
61
            // Selected database driver
62
            Driver\DriverInterface::class => function($di) {
63
                // Register a driver for each database server.
64
                $package = $di->g(Lagdo\DbAdmin\DbAdminPackage::class);
65
                foreach($package->getServers() as $server => $options) {
66
                    $di->set("dbadmin_driver_$server", fn() =>
67
                        Driver\Driver::createDriver($options));
68
                }
69
70
                $server = $di->g('dbadmin_config_server');
71
                return $di->g("dbadmin_driver_$server");
72
            },
73
            // Facades to the DB driver features
74
            Db\Facades\CommandFacade::class => function($di) {
75
                $dbFacade = $di->g(Db\DbFacade::class);
76
                $timer = $di->g(Service\TimerService::class);
77
                $logger = $di->g(Service\LogWriter::class);
0 ignored issues
show
Bug introduced by
The type Lagdo\DbAdmin\Service\LogWriter 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...
78
                return new Db\Facades\CommandFacade($dbFacade, $timer, $logger);
79
            },
80
            Db\Facades\DatabaseFacade::class => function($di) {
81
                $dbFacade = $di->g(Db\DbFacade::class);
82
                $server = $di->g('dbadmin_config_server');
83
                $package = $di->g(Lagdo\DbAdmin\DbAdminPackage::class);
84
                $options = $package->getServerOptions($server);
85
                return new Db\Facades\DatabaseFacade($dbFacade, $options);
86
            },
87
            Db\Facades\ExportFacade::class => function($di) {
88
                $dbFacade = $di->g(Db\DbFacade::class);
89
                return new Db\Facades\ExportFacade($dbFacade);
90
            },
91
            Db\Facades\ImportFacade::class => function($di) {
92
                $dbFacade = $di->g(Db\DbFacade::class);
93
                $timer = $di->g(Service\TimerService::class);
94
                $logger = $di->g(Service\LogWriter::class);
95
                return new Db\Facades\ImportFacade($dbFacade, $timer, $logger);
96
            },
97
            Db\Facades\QueryFacade::class => function($di) {
98
                $dbFacade = $di->g(Db\DbFacade::class);
99
                return new Db\Facades\QueryFacade($dbFacade);
100
            },
101
            Db\Facades\SelectFacade::class => function($di) {
102
                $dbFacade = $di->g(Db\DbFacade::class);
103
                $timer = $di->g(Service\TimerService::class);
104
                return new Db\Facades\SelectFacade($dbFacade, $timer);
105
            },
106
            Db\Facades\ServerFacade::class => function($di) {
107
                $dbFacade = $di->g(Db\DbFacade::class);
108
                $server = $di->g('dbadmin_config_server');
109
                $package = $di->g(Lagdo\DbAdmin\DbAdminPackage::class);
110
                $options = $package->getServerOptions($server);
111
                return new Db\Facades\ServerFacade($dbFacade, $options);
112
            },
113
            Db\Facades\TableFacade::class => function($di) {
114
                $dbFacade = $di->g(Db\DbFacade::class);
115
                return new Db\Facades\TableFacade($dbFacade);
116
            },
117
            Db\Facades\UserFacade::class => function($di) {
118
                $dbFacade = $di->g(Db\DbFacade::class);
119
                return new Db\Facades\UserFacade($dbFacade);
120
            },
121
            Db\Facades\ViewFacade::class => function($di) {
122
                $dbFacade = $di->g(Db\DbFacade::class);
123
                return new Db\Facades\ViewFacade($dbFacade);
124
            },
125
            Config\UserFileReader::class => function() {
126
                return new Config\UserFileReader(getAuth());
0 ignored issues
show
Bug introduced by
The call to getAuth() has too few arguments starting with di. ( Ignorable by Annotation )

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

126
                return new Config\UserFileReader(/** @scrutinizer ignore-call */ getAuth());

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
127
            },
128
            // Query logging
129
            Service\Logging\QueryLogger::class => function($di) {
130
                $package = $di->g(Lagdo\DbAdmin\LoggingPackage::class);
131
                $database = $package->getOption('database');
132
                $options = $package->getOption('options', []);
133
                if (!is_array($database) || !is_array($options)) {
134
                    return null;
135
                }
136
137
                $driver = Driver\Driver::createDriver($database);
138
                $reader = $di->g(Config\UserFileReader::class);
139
                $db = $di->g(Db\DbFacade::class);
140
                return new Service\Logging\QueryLogger($db, $driver,
0 ignored issues
show
Bug introduced by
It seems like $driver can also be of type null; however, parameter $driver of Lagdo\DbAdmin\Service\Lo...ryLogger::__construct() does only seem to accept Lagdo\DbAdmin\Driver\DriverInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

140
                return new Service\Logging\QueryLogger($db, /** @scrutinizer ignore-type */ $driver,
Loading history...
141
                    $reader->getServerOptions($database), $options);
142
            },
143
        ],
144
        'auto' => [
145
            // The translator
146
            Lagdo\DbAdmin\Translator::class,
147
            // The string manipulation class
148
            Driver\Utils\Str::class,
149
            // The user input
150
            Driver\Utils\Input::class,
151
            // The utils class
152
            Driver\Utils\Utils::class,
153
            // The facade to the database features
154
            Db\DbFacade::class,
155
            // The Timer service
156
            Service\TimerService::class,
157
            // The db classes
158
            Admin\Admin::class,
159
            // The UI builders
160
            Ui\UiBuilder::class,
161
            Ui\InputBuilder::class,
162
            Ui\MenuBuilder::class,
163
            Ui\Logging\LogUiBuilder::class,
164
        ],
165
        'alias' => [
166
            // The translator
167
            Driver\Utils\TranslatorInterface::class => Lagdo\DbAdmin\Translator::class,
168
        ],
169
    ],
170
    'exceptions' => [
171
        Db\Exception\DbException::class => function(Db\Exception\DbException $dbException) {
172
            $response = jaxon()->getResponse();
173
            $response->dialog->warning($dbException->getMessage());
0 ignored issues
show
Bug introduced by
The method warning() does not exist on null. ( Ignorable by Annotation )

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

173
            $response->dialog->/** @scrutinizer ignore-call */ 
174
                               warning($dbException->getMessage());

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...
Bug introduced by
The method warning() does not exist on Jaxon\Plugin\ResponsePluginInterface. It seems like you code against a sub-type of Jaxon\Plugin\ResponsePluginInterface such as Jaxon\Plugin\Response\Dialog\DialogPlugin. ( Ignorable by Annotation )

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

173
            $response->dialog->/** @scrutinizer ignore-call */ 
174
                               warning($dbException->getMessage());
Loading history...
174
            return $response;
175
        },
176
    ],
177
];
178