Completed
Push — master ( 5e6003...ff6361 )
by Matthew
03:07
created

DatabaseDataServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Ps2alerts\Api\ServiceProvider;
4
5
use Aura\Sql\ExtendedPdo;
6
use League\Container\ServiceProvider;
7
8
class DatabaseDataServiceProvider extends ServiceProvider
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $provides = [
14
        'Database\Data'
15
    ];
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function register()
21
    {
22
        $this->getContainer()->singleton('Database\Data', function () {
23
            $config = $this->getContainer()->get('config')['database_data'];
24
25
            $pdo = new ExtendedPdo(
26
                "mysql:host={$config['host']};dbname={$config['schema']}",
27
                $config['user'],
28
                $config['password']
29
            );
30
31
            return $pdo;
32
        });
33
    }
34
}
35