Issues (9)

src/Database/ServiceProvider.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Gravatalonga\Framework\Database;
4
5
use Aura\Sql\ExtendedPdo;
0 ignored issues
show
The type Aura\Sql\ExtendedPdo 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...
6
use Psr\Container\ContainerInterface;
7
use Gravatalonga\Interfaces\ServiceProviderInterface;
0 ignored issues
show
The type Gravatalonga\Interfaces\ServiceProviderInterface 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...
8
9
class ServiceProvider implements ServiceProviderInterface
10
{
11
    public function register(): array
12
    {
13
        return [
14
            'database' => function (ContainerInterface $container) {
15
                $database = $container->get('config.database');
16
                $name = $database['name'];
17
                $connection = $database['connections'][$name];
18
                return new ExtendedPdo(
19
                    $connection['database_type'].':host='.$connection['server'].';dbname='.$connection['database_name'],
20
                    $connection['username'],
21
                    $connection['password'],
22
                    [], // driver attributes/options as key-value pairs
23
                    []  // queries to execute after connection
24
                );
25
            }
26
        ];
27
    }
28
}
29