Test Failed
Push — master ( 5851fa...90c56e )
by Maximo
02:00
created

DatabaseProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 1
1
<?php
0 ignored issues
show
Coding Style introduced by
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Providers;
6
7
use function Gewaer\Core\envValue;
8
use Phalcon\Db\Adapter\Pdo\Mysql;
9
use Phalcon\Di\ServiceProviderInterface;
10
use Phalcon\DiInterface;
11
12
class DatabaseProvider implements ServiceProviderInterface
13
{
14
    /**
15
     * @param DiInterface $container
16
     */
17 12
    public function register(DiInterface $container)
18
    {
19 12
        $container->setShared(
20 12
            'db',
21
            function () {
22
                $options = [
23 12
                    'host' => envValue('DATA_API_MYSQL_HOST', 'localhost'),
24 12
                    'username' => envValue('DATA_API_MYSQL_USER', 'nanobox'),
25 12
                    'password' => envValue('DATA_API_MYSQL_PASS', ''),
26 12
                    'dbname' => envValue('DATA_API_MYSQL_NAME', 'gonano'),
27 12
                    'charset' => 'utf8',
28
                ];
29
30 12
                $connection = new Mysql($options);
31
                // Set everything to UTF8
32 12
                $connection->execute('SET NAMES utf8mb4', []);
33
34 12
                return $connection;
35 12
            }
36
        );
37 12
    }
38
}
39