Passed
Push — master ( de3595...5928a0 )
by dima
05:09
created

ServiceProvider::register()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 24
rs 8.9714
cc 1
eloc 19
nc 1
nop 0
1
<?php
2
3
namespace Test;
4
5
use League\Container\ServiceProvider\AbstractServiceProvider;
6
7
/**
8
 * Description of ServiceProvider
9
 *
10
 * @author d.lanec
11
 */
12
class ServiceProvider extends AbstractServiceProvider {
13
	
14
	protected $provides = [
15
		'UserMapper',
16
		'UserGroupMapper',
17
		'UserGroupMapper',
18
		'CityMapper'
19
	];
20
	
21
	public function register() {
22
		
23
		global $__AR2, $CONST;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
24
		
25
		$db = new \SimpleORM\Adapter\CodeigniterQueryBuilder(get_instance()->db);
26
		
27
		$this->getContainer()->add('UserMapper','Test\Domain\User\UserMapper')
28
				->withArgument($this->getContainer())
29
				->withArgument($db)
30
				->withArgument($__AR2['autoresource_db']);
31
		
32
		$this->getContainer()->add('UserGroupMapper','Test\Domain\UserGroup\UserGroupMapper')
33
				->withArgument($this->getContainer())
34
				->withArgument($db)
35
				->withArgument($__AR2['autoresource_db']);	
36
		$this->getContainer()->add('UserAddressMapper','Test\Domain\UserAddress\UserAddressMapper')
37
				->withArgument($this->getContainer())
38
				->withArgument($db)
39
				->withArgument($__AR2['autoresource_db']);	
40
		$this->getContainer()->add('CityMapper','Test\Domain\City\CityMapper')
41
				->withArgument($this->getContainer())
42
				->withArgument($db)
43
				->withArgument($__AR2['autoresource_db']);	
44
	}	
45
}
46