Completed
Pull Request — master (#115)
by Thomas
03:36
created

Application::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 57
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 1.0939

Importance

Changes 4
Bugs 0 Features 2
Metric Value
c 4
b 0
f 2
dl 0
loc 57
ccs 24
cts 44
cp 0.5455
rs 9.6818
cc 1
eloc 35
nc 1
nop 1
crap 1.0939

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * ownCloud - maps
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Sander Brand <[email protected]>
9
 * @copyright Sander Brand 2014
10
 */
11
12
namespace OCA\Maps\AppInfo;
13
14
15
use \OCP\AppFramework\App;
16
use \OCA\Maps\Db\CacheManager;
17
use \OCA\Maps\Db\DeviceMapper;
18
use \OCA\Maps\Db\LocationMapper;
19
use \OCA\Maps\Db\FavoriteMapper;
20
use \OCA\Maps\Controller\PageController;
21
use \OCA\Maps\Controller\LocationController;
22
use \OCA\Maps\Controller\FavoriteController;
23
24
25
class Application extends App {
26
27
28 1
	public function __construct (array $urlParams=array()) {
29 1
		parent::__construct('maps', $urlParams);
30
31 1
		$container = $this->getContainer();
32
33
		/**
34
		 * Controllers
35
		 */
36
		$container->registerService('PageController', function($c) {
37 1
			return new PageController(
38 1
				$c->query('AppName'),
39 1
				$c->query('Request'),
40 1
				$c->query('UserId'),
41 1
				$c->query('CacheManager'),
42 1
				$c->query('DeviceMapper')
43
			);
44 1
		});
45
		$container->registerService('LocationController', function($c) {
46
			return new LocationController(
47
				$c->query('AppName'),
48
				$c->query('Request'),
49
				$c->query('LocationMapper'),
50
				$c->query('DeviceMapper'),
51
				$c->query('UserId')
52
			);
53 1
		});
54
		$container->registerService('FavoriteController', function($c) {
55
			return new FavoriteController(
56
				$c->query('AppName'),
57
				$c->query('Request'),
58
				$c->query('FavoriteMapper'),
59
				$c->query('UserId')
60
			);
61 1
		});
62
63
		$container->registerService('CacheManager', function($c) {
64 1
			return new CacheManager(
65 1
				$c->query('ServerContainer')->getDb()
66 1
			);
67 1
		});
68
		$container->registerService('LocationMapper', function($c) {
69
			return new LocationMapper(
70
				$c->query('ServerContainer')->getDb()
71
			);
72 1
		});
73
		$container->registerService('DeviceMapper', function($c) {
74 1
			return new DeviceMapper(
75 1
				$c->query('ServerContainer')->getDb()
76 1
			);
77 1
		});
78 1
		$container->registerService('FavoriteMapper', function($c) {
79
			return new FavoriteMapper(
80
				$c->query('ServerContainer')->getDb()
81
			);
82 1
		});
83
84 1
	}
85
86
87
}
88