Test Failed
Push — master ( af6147...dbfe7c )
by Maximo
11:22 queued 06:20
created

DatabaseProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 29
ccs 12
cts 14
cp 0.8571
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 24 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Providers;
6
7
use function Canvas\Core\envValue;
8
use Phalcon\Db\Adapter\Pdo\Mysql;
0 ignored issues
show
Bug introduced by
The type Phalcon\Db\Adapter\Pdo\Mysql 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...
9
use Phalcon\Di\ServiceProviderInterface;
0 ignored issues
show
Bug introduced by
The type Phalcon\Di\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...
10
use Phalcon\DiInterface;
0 ignored issues
show
Bug introduced by
The type Phalcon\DiInterface 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...
11
use PDOException;
12
use Canvas\Exception\ServerErrorHttpException;
13
use PDO;
14
15
class DatabaseProvider implements ServiceProviderInterface
16
{
17
    /**
18
     * @param DiInterface $container
19
     */
20 5
    public function register(DiInterface $container)
21
    {
22 5
        $container->setShared(
23 5
            'db',
24 5
            function () {
25
                $options = [
26 2
                    'host' => envValue('DATA_API_MYSQL_HOST', 'localhost'),
27 2
                    'username' => envValue('DATA_API_MYSQL_USER', 'nanobox'),
28 2
                    'password' => envValue('DATA_API_MYSQL_PASS', ''),
29 2
                    'dbname' => envValue('DATA_API_MYSQL_NAME', 'gonano'),
30 2
                    'charset' => 'utf8',
31
                    "options" => [ PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING ]
32
                ];
33
34
                try {
35 2
                    $connection = new Mysql($options);
36
37
                    // Set everything to UTF8
38 2
                    $connection->execute('SET NAMES utf8mb4', []);
39
                } catch (PDOException $e) {
40
                    throw new ServerErrorHttpException($e->getMessage());
41
                }
42
43 2
                return $connection;
44 5
            }
45
        );
46 5
    }
47
}
48