EloquentServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 20 1
1
<?php
2
/**
3
 * This file is part of user_management
4
 * User: Sinan TURGUT <[email protected]>
5
 * Date: 24.06.2019
6
 * php version 7.2
7
 *
8
 * @category Assessment
9
 * @package  UserManagement
10
 * @author   Sinan TURGUT <[email protected]>
11
 * @license  See LICENSE file
12
 * @link     https://dev.sinanturgut.com.tr
13
 */
14
15
namespace UserManagement\Services\Database;
16
17
use Illuminate\Database\Capsule\Manager;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Capsule\Manager 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...
18
use Pimple\Container;
0 ignored issues
show
Bug introduced by
The type Pimple\Container 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...
19
use Pimple\ServiceProviderInterface;
0 ignored issues
show
Bug introduced by
The type Pimple\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...
20
21
/**
22
 * Class EloquentServiceProvider
23
 * @package UserManagement\Services\Database
24
 */
25
class EloquentServiceProvider implements ServiceProviderInterface
26
{
27
28
    /**
29
     * @param Container $pimple
30
     */
31
    public function register(Container $pimple)
32
    {
33
        $capsule = new Manager();
34
        $config = $pimple['settings']['database'];
35
36
        $capsule->addConnection([
37
            'driver'    => $config['driver'],
38
            'host'      => $config['host'],
39
            'database'  => $config['database'],
40
            'username'  => $config['username'],
41
            'password'  => $config['password'],
42
            'charset'   => 'utf8',
43
            'collation' => 'utf8_unicode_ci',
44
            'prefix'    => '',
45
        ]);
46
47
        $capsule->setAsGlobal();
48
        $capsule->bootEloquent();
49
        $pimple['db'] = function ($c) use ($capsule) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

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

49
        $pimple['db'] = function (/** @scrutinizer ignore-unused */ $c) use ($capsule) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
            return $capsule;
51
        };
52
    }
53
}