Completed
Pull Request — master (#93)
by Janis
11:26
created
lib/Settings/Section.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	 *
39 39
 	 */
40 40
 	public function getName() {
41
-		return $this->l->t ( 'OCR' );
41
+		return $this->l->t('OCR');
42 42
 	}
43 43
 	/**
44 44
 	 *
Please login to merge, or discard this patch.
lib/Settings/Admin.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
 	 * @return TemplateResponse
32 32
 	 */
33 33
 	public function getForm() {
34
-		return new TemplateResponse( 'ocr', 'settings-admin', [ 
35
-				'languages' => $this->config->getAppValue ( 'ocr', 'languages' ) 
36
-		], 'blank' );
34
+		return new TemplateResponse('ocr', 'settings-admin', [ 
35
+				'languages' => $this->config->getAppValue('ocr', 'languages') 
36
+		], 'blank');
37 37
 	}
38 38
 	/**
39 39
 	 *
Please login to merge, or discard this patch.
lib/Service/AppConfigService.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return string
52 52
 	 */
53 53
 	public function getAppValue($key) {
54
-		return $this->config->getAppValue ( $this->appName, $key );
54
+		return $this->config->getAppValue($this->appName, $key);
55 55
 	}
56 56
 	/**
57 57
 	 * Set a value by key
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function setAppValue($key, $value) {
64 64
 		if ($key === 'languages') {
65
-			if (! preg_match ( '/^(([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4});)*([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4})$/', $value )) {
66
-				throw new NotFoundException ( $this->l10n->t ( 'The languages are not specified in the correct format.' ) );
65
+			if (!preg_match('/^(([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4});)*([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4})$/', $value)) {
66
+				throw new NotFoundException($this->l10n->t('The languages are not specified in the correct format.'));
67 67
 			}
68 68
 		}
69
-		return $this->config->setAppValue ( $this->appName, $key, $value );
69
+		return $this->config->setAppValue($this->appName, $key, $value);
70 70
 	}
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Controller/AdminSettingsController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param string $userId        	
40 40
 	 */
41 41
 	public function __construct($appName, IRequest $request, IL10N $l10n, AppConfigService $appConfig, $userId) {
42
-		parent::__construct ( $appName, $request );
42
+		parent::__construct($appName, $request);
43 43
 		$this->l10n = $l10n;
44 44
 		$this->appConfig = $appConfig;
45 45
 	}
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 * @return DataResponse
51 51
 	 */
52 52
 	public function getSettings() {
53
-		return $this->handleNotFound ( function () {
54
-			return [ 'languages' => $this->appConfig->getAppValue ( 'languages' )];
53
+		return $this->handleNotFound(function() {
54
+			return ['languages' => $this->appConfig->getAppValue('languages')];
55 55
 		} );
56 56
 	}
57 57
 	
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
 	 * @return DataResponse
63 63
 	 */
64 64
 	public function setSettings($languages) {
65
-		return $this->handleNotFound ( function () use ($languages) {
65
+		return $this->handleNotFound(function() use ($languages) {
66 66
 			if ($languages !== null) {
67
-				$this->appConfig->setAppValue ( 'languages', $languages );
68
-				return $this->l10n->t ( 'Saved' );
67
+				$this->appConfig->setAppValue('languages', $languages);
68
+				return $this->l10n->t('Saved');
69 69
 			} else {
70
-				throw new NotFoundException ( $this->l10n->t ( 'The languages are not specified in the correct format.' ) );
70
+				throw new NotFoundException($this->l10n->t('The languages are not specified in the correct format.'));
71 71
 			}
72 72
 		} );
73 73
 	}
Please login to merge, or discard this patch.
lib/AppInfo/Application.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -39,130 +39,130 @@  discard block
 block discarded – undo
39 39
 	 * @param array $urlParams        	
40 40
 	 */
41 41
 	public function __construct(array $urlParams = array()) {
42
-		parent::__construct ( 'ocr', $urlParams );
43
-		$container = $this->getContainer ();
42
+		parent::__construct('ocr', $urlParams);
43
+		$container = $this->getContainer();
44 44
 		
45 45
 		/**
46 46
 		 * Add the js and style if OCA\Files app is loaded
47 47
 		 */
48
-		$eventDispatcher = \OC::$server->getEventDispatcher ();
49
-		$eventDispatcher->addListener ( 'OCA\Files::loadAdditionalScripts', function () {
50
-			script ( 'ocr', 'dist/ocrapp' );
51
-			style ( 'ocr', 'ocrstyle' );
48
+		$eventDispatcher = \OC::$server->getEventDispatcher();
49
+		$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() {
50
+			script('ocr', 'dist/ocrapp');
51
+			style('ocr', 'ocrstyle');
52 52
 			// if not loaded before - load select2 for multi select languages
53
-			vendor_script ( 'select2/select2' );
54
-			vendor_style ( 'select2/select2' );
53
+			vendor_script('select2/select2');
54
+			vendor_style('select2/select2');
55 55
 		} );
56 56
 		
57 57
 		/**
58 58
 		 * Register core services
59 59
 		 */
60
-		$container->registerService ( 'CurrentUID', function (IContainer $c) {
60
+		$container->registerService('CurrentUID', function(IContainer $c) {
61 61
 			/** @var \OC\Server $server */
62
-			$server = $c->query ( 'ServerContainer' );
63
-			$user = $server->getUserSession ()->getUser ();
64
-			return ($user) ? $user->getUID () : '';
62
+			$server = $c->query('ServerContainer');
63
+			$user = $server->getUserSession()->getUser();
64
+			return ($user) ? $user->getUID() : '';
65 65
 		} );
66 66
 		
67 67
 		// Allow automatic DI for the View, until they migrated to Nodes API
68
-		$container->registerService ( View::class, function () {
69
-			return new View ( '' );
70
-		}, false );
68
+		$container->registerService(View::class, function() {
69
+			return new View('');
70
+		}, false);
71 71
 		
72 72
 		/**
73 73
 		 * Register the Ocr Job mapper
74 74
 		 */
75
-		$container->registerService ( 'OcrJobMapper', function (IContainer $c) {
75
+		$container->registerService('OcrJobMapper', function(IContainer $c) {
76 76
 			/** @var \OC\Server $server */
77
-			$server = $c->query ( 'ServerContainer' );
78
-			return new OcrJobMapper ( $server->getDatabaseConnection () );
77
+			$server = $c->query('ServerContainer');
78
+			return new OcrJobMapper($server->getDatabaseConnection());
79 79
 		} );
80 80
 		
81 81
 		/**
82 82
 		 * Register the File mapper
83 83
 		 */
84
-		$container->registerService ( 'FileMapper', function (IContainer $c) {
84
+		$container->registerService('FileMapper', function(IContainer $c) {
85 85
 			/** @var \OC\Server $server */
86
-			$server = $c->query ( 'ServerContainer' );
87
-			return new FileMapper ( $server->getDatabaseConnection () );
86
+			$server = $c->query('ServerContainer');
87
+			return new FileMapper($server->getDatabaseConnection());
88 88
 		} );
89 89
 		
90 90
 		/**
91 91
 		 * Register the Share mapper
92 92
 		 */
93
-		$container->registerService ( 'ShareMapper', function (IContainer $c) {
93
+		$container->registerService('ShareMapper', function(IContainer $c) {
94 94
 			/** @var \OC\Server $server */
95
-			$server = $c->query ( 'ServerContainer' );
96
-			return new ShareMapper ( $server->getDatabaseConnection () );
95
+			$server = $c->query('ServerContainer');
96
+			return new ShareMapper($server->getDatabaseConnection());
97 97
 		} );
98 98
 		
99 99
 		/**
100 100
 		 * Register the App Config Service
101 101
 		 */
102
-		$container->registerService ( 'AppConfigService', function (IAppContainer $c) {
102
+		$container->registerService('AppConfigService', function(IAppContainer $c) {
103 103
 			/** @var \OC\Server $server */
104
-			$server = $c->query ( 'ServerContainer' );
105
-			return new AppConfigService( $server->getConfig (), $server->getL10N ( 'ocr' ) );
104
+			$server = $c->query('ServerContainer');
105
+			return new AppConfigService($server->getConfig(), $server->getL10N('ocr'));
106 106
 		} );
107 107
 		
108 108
 		/**
109 109
 		 * Register the Redis Service
110 110
 		 */
111
-		$container->registerService ( 'RedisService', function (IAppContainer $c) {
111
+		$container->registerService('RedisService', function(IAppContainer $c) {
112 112
 			/** @var \OC\Server $server */
113
-			$server = $c->query ( 'ServerContainer' );
114
-			return new RedisService ( $c->query ( 'OcrJobMapper' ), $server->getConfig (), $server->getL10N ( 'ocr' ), $server->getLogger () );
113
+			$server = $c->query('ServerContainer');
114
+			return new RedisService($c->query('OcrJobMapper'), $server->getConfig(), $server->getL10N('ocr'), $server->getLogger());
115 115
 		} );
116 116
 		
117 117
 		/**
118 118
 		 * Register the Job Service
119 119
 		 */
120
-		$container->registerService ( 'FileService', function (IAppContainer $c) {
120
+		$container->registerService('FileService', function(IAppContainer $c) {
121 121
 			/** @var \OC\Server $server */
122
-			$server = $c->query ( 'ServerContainer' );
123
-			return new FileService ( $server->getL10N ( 'ocr' ), $server->getLogger (), $c->query ( 'CurrentUID' ), $c->query ( 'FileMapper' ), $c->query ( 'ShareMapper' ) );
122
+			$server = $c->query('ServerContainer');
123
+			return new FileService($server->getL10N('ocr'), $server->getLogger(), $c->query('CurrentUID'), $c->query('FileMapper'), $c->query('ShareMapper'));
124 124
 		} );
125 125
 		
126 126
 		/**
127 127
 		 * Register the Job Service
128 128
 		 */
129
-		$container->registerService ( 'JobService', function (IAppContainer $c) {
129
+		$container->registerService('JobService', function(IAppContainer $c) {
130 130
 			/** @var \OC\Server $server */
131
-			$server = $c->query ( 'ServerContainer' );
132
-			return new JobService ( $server->getL10N ( 'ocr' ), $server->getLogger (), $c->query ( 'CurrentUID' ), new View ( '/' . $c->query ( 'CurrentUID' ) . '/files' ), $server->getTempManager (), $c->query ( 'RedisService' ), $c->query ( 'OcrJobMapper' ), $c->query ( 'FileService' ), $c->query ( 'AppConfigService' ) );
131
+			$server = $c->query('ServerContainer');
132
+			return new JobService($server->getL10N('ocr'), $server->getLogger(), $c->query('CurrentUID'), new View('/' . $c->query('CurrentUID') . '/files'), $server->getTempManager(), $c->query('RedisService'), $c->query('OcrJobMapper'), $c->query('FileService'), $c->query('AppConfigService'));
133 133
 		} );
134 134
 		
135 135
 		/**
136 136
 		 * Register the Status Service
137 137
 		 */
138
-		$container->registerService ( 'StatusService', function (IAppContainer $c) {
138
+		$container->registerService('StatusService', function(IAppContainer $c) {
139 139
 			/** @var \OC\Server $server */
140
-			$server = $c->query ( 'ServerContainer' );
141
-			return new StatusService ( $server->getL10N ( 'ocr' ), $server->getLogger (), $c->query ( 'CurrentUID' ), $c->query ( 'OcrJobMapper' ), $c->query ( 'JobService' ) );
140
+			$server = $c->query('ServerContainer');
141
+			return new StatusService($server->getL10N('ocr'), $server->getLogger(), $c->query('CurrentUID'), $c->query('OcrJobMapper'), $c->query('JobService'));
142 142
 		} );
143 143
 		
144 144
 		/**
145 145
 		 * Controller
146 146
 		 */
147
-		$container->registerService ( 'StatusController', function (IAppContainer $c) {
147
+		$container->registerService('StatusController', function(IAppContainer $c) {
148 148
 			/** @var \OC\Server $server */
149
-			$server = $c->query ( 'ServerContainer' );
150
-			return new StatusController ( $c->getAppName (), $server->getRequest (), $c->query ( 'StatusService' ) );
149
+			$server = $c->query('ServerContainer');
150
+			return new StatusController($c->getAppName(), $server->getRequest(), $c->query('StatusService'));
151 151
 		} );
152 152
 		
153 153
 		/**
154 154
 		 * Controller
155 155
 		 */
156
-		$container->registerService ( 'JobController', function (IAppContainer $c) {
156
+		$container->registerService('JobController', function(IAppContainer $c) {
157 157
 			/** @var \OC\Server $server */
158
-			$server = $c->query ( 'ServerContainer' );
159
-			return new JobController ( $c->getAppName (), $server->getRequest (), $c->query ( 'JobService' ), $c->query ( 'CurrentUID' ) );
158
+			$server = $c->query('ServerContainer');
159
+			return new JobController($c->getAppName(), $server->getRequest(), $c->query('JobService'), $c->query('CurrentUID'));
160 160
 		} );
161 161
 		
162 162
 		/**
163 163
 		 * Controller
164 164
 		 */
165
-		$container->registerAlias ( 'PersonalSettingsController', PersonalSettingsController::class );
165
+		$container->registerAlias('PersonalSettingsController', PersonalSettingsController::class);
166 166
 	}
167 167
 	
168 168
 	/**
@@ -170,6 +170,6 @@  discard block
 block discarded – undo
170 170
 	 * @codeCoverageIgnore
171 171
 	 */
172 172
 	public function registerPersonal() {
173
-		\OCP\App::registerPersonal ( $this->getContainer ()->getAppName (), 'personal' );
173
+		\OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal');
174 174
 	}
175 175
 }
Please login to merge, or discard this patch.
lib/Controller/JobController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 *        	$UserId
48 48
 	 */
49 49
 	public function __construct($AppName, IRequest $request, JobService $service, $UserId) {
50
-		parent::__construct ( $AppName, $request );
50
+		parent::__construct($AppName, $request);
51 51
 		$this->userId = $UserId;
52 52
 		$this->service = $service;
53 53
 	}
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @return DataResponse
63 63
 	 */
64 64
 	public function process($languages, $files) {
65
-		return $this->handleNotFound ( function () use ($languages, $files) {
66
-			return $this->service->process ( $languages, $files );
65
+		return $this->handleNotFound(function() use ($languages, $files) {
66
+			return $this->service->process($languages, $files);
67 67
 		} );
68 68
 	}
69 69
 	
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @return \OCP\AppFramework\Http\DataResponse
74 74
 	 */
75 75
 	public function getAllJobs() {
76
-		return $this->handleNotFound ( function () {
77
-			return $this->service->getAllJobsForUser ( $this->userId );
76
+		return $this->handleNotFound(function() {
77
+			return $this->service->getAllJobsForUser($this->userId);
78 78
 		} );
79 79
 	}
80 80
 	
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @return \OCP\AppFramework\Http\DataResponse
86 86
 	 */
87 87
 	public function deleteJob($id) {
88
-		return $this->handleNotFound ( function () use ($id) {
89
-			return $this->service->deleteJob ( $id, $this->userId );
88
+		return $this->handleNotFound(function() use ($id) {
89
+			return $this->service->deleteJob($id, $this->userId);
90 90
 		} );
91 91
 	}
92 92
 }
93 93
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/FileService.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	public function checkSharedWithInitiator($fileInfo) {
74 74
 		try {
75
-			$owner = str_replace ( 'home::', '', $fileInfo->getStoragename () );
75
+			$owner = str_replace('home::', '', $fileInfo->getStoragename());
76 76
 			if ($this->userId === $owner) {
77 77
 				// user is owner (no shared file)
78 78
 				return false;
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 				// user is not owner (shared file)
81 81
 				return true;
82 82
 			}
83
-		} catch ( Exception $e ) {
84
-			$this->handleException ( $e );
83
+		} catch (Exception $e) {
84
+			$this->handleException($e);
85 85
 		}
86 86
 	}
87 87
 	
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function buildTarget($fileInfo, $shared) {
96 96
 		if ($shared) {
97
-			$target = $this->buildTargetForShared ( $fileInfo );
97
+			$target = $this->buildTargetForShared($fileInfo);
98 98
 		} else {
99
-			$target = $this->buildTargetNotForShared ( $fileInfo );
99
+			$target = $this->buildTargetNotForShared($fileInfo);
100 100
 		}
101 101
 		return $target;
102 102
 	}
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 	 * @return string
110 110
 	 */
111 111
 	public function buildSource($fileInfo, $shared) {
112
-		$source = $fileInfo->getPath ();
112
+		$source = $fileInfo->getPath();
113 113
 		if ($shared) {
114
-			$source = str_replace ( 'home::', '', $fileInfo->getStoragename () ) . '/' . $source;
114
+			$source = str_replace('home::', '', $fileInfo->getStoragename()) . '/' . $source;
115 115
 		} else {
116 116
 			$source = $this->userId . '/' . $source;
117 117
 		}
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function buildFileInfo($files) {
130 130
 		try {
131
-			$fileArray = array ();
132
-			foreach ( $files as $file ) {
131
+			$fileArray = array();
132
+			foreach ($files as $file) {
133 133
 				// Check if anything is missing and file type is correct
134
-				if (! empty ( $file ['id'] )) {
134
+				if (!empty ($file ['id'])) {
135 135
 					
136
-					$fileInfo = $this->fileMapper->find ( $file ['id'] );
137
-					$this->checkMimeType ( $fileInfo );
136
+					$fileInfo = $this->fileMapper->find($file ['id']);
137
+					$this->checkMimeType($fileInfo);
138 138
 					
139
-					array_push ( $fileArray, $fileInfo );
139
+					array_push($fileArray, $fileInfo);
140 140
 				} else {
141
-					throw new NotFoundException ( $this->l10n->t ( 'Wrong parameter.' ) );
141
+					throw new NotFoundException($this->l10n->t('Wrong parameter.'));
142 142
 				}
143 143
 			}
144 144
 			return $fileArray;
145
-		} catch ( Exception $e ) {
146
-			$this->handleException ( $e );
145
+		} catch (Exception $e) {
146
+			$this->handleException($e);
147 147
 		}
148 148
 	}
149 149
 	
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @return string
155 155
 	 */
156 156
 	public function removeFileExtension($job) {
157
-		return substr ( $job->getTarget (), 0, strrpos ( $job->getTarget (), '_OCR' ) );
157
+		return substr($job->getTarget(), 0, strrpos($job->getTarget(), '_OCR'));
158 158
 	}
159 159
 	
160 160
 	/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @return integer
165 165
 	 */
166 166
 	public function getCorrectType($fileInfo) {
167
-		if ($fileInfo->getMimetype () === OcrConstants::MIME_TYPE_PDF) {
167
+		if ($fileInfo->getMimetype() === OcrConstants::MIME_TYPE_PDF) {
168 168
 			return OcrConstants::OCRmyPDF;
169 169
 		} else {
170 170
 			return OcrConstants::TESSERACT;
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param string $pathToFile        	
180 180
 	 */
181 181
 	public function execRemove($pathToFile) {
182
-		exec ( 'rm ' . $pathToFile );
182
+		exec('rm ' . $pathToFile);
183 183
 	}
184 184
 	
185 185
 	/**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @return string
192 192
 	 */
193 193
 	public function getFileContents($pathToFile) {
194
-		return file_get_contents ( $pathToFile );
194
+		return file_get_contents($pathToFile);
195 195
 	}
196 196
 	
197 197
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return boolean
204 204
 	 */
205 205
 	public function fileExists($pathToFile) {
206
-		return file_exists ( $pathToFile );
206
+		return file_exists($pathToFile);
207 207
 	}
208 208
 	
209 209
 	/**
@@ -218,32 +218,32 @@  discard block
 block discarded – undo
218 218
 	 */
219 219
 	protected function buildTargetForShared(File $fileInfo) {
220 220
 		try {
221
-			$share = $this->shareMapper->find ( $fileInfo->getFileid (), $this->userId, str_replace ( 'home::', '', $fileInfo->getStoragename () ) );
221
+			$share = $this->shareMapper->find($fileInfo->getFileid(), $this->userId, str_replace('home::', '', $fileInfo->getStoragename()));
222 222
 			
223 223
 			// get rid of the .png or .pdf and so on
224
-			$fileName = substr ( $share->getFileTarget (), 0, (strrpos ( $share->getFileTarget (), '.' )) ); // '/thedom.png' => '/thedom' || '/Test/thedom.png' => '/Test/thedom'
224
+			$fileName = substr($share->getFileTarget(), 0, (strrpos($share->getFileTarget(), '.'))); // '/thedom.png' => '/thedom' || '/Test/thedom.png' => '/Test/thedom'
225 225
 			                                                                                                 
226 226
 			// remove everything in front of and including of the first appearance of a slash from behind
227
-			$fileName = substr ( strrchr ( $fileName, "/" ), 1 ); // '/thedom' => 'thedom' || '/Test/thedom' => 'thedom'
227
+			$fileName = substr(strrchr($fileName, "/"), 1); // '/thedom' => 'thedom' || '/Test/thedom' => 'thedom'
228 228
 			                                                      
229 229
 			// eliminate the file name from the path
230
-			$filePath = dirname ( $share->getFileTarget () ); // '/thedom.png' => '/' || '/Test/thedom.png' => '/Test'
230
+			$filePath = dirname($share->getFileTarget()); // '/thedom.png' => '/' || '/Test/thedom.png' => '/Test'
231 231
 			                                                  
232 232
 			// replace the first slash
233
-			$pos = strpos ( $filePath, '/' );
233
+			$pos = strpos($filePath, '/');
234 234
 			if ($pos !== false) {
235
-				$filePath = substr_replace ( $filePath, '', $pos, strlen ( '/' ) ); // '/' => '' || '/Test/' => 'Test'
235
+				$filePath = substr_replace($filePath, '', $pos, strlen('/')); // '/' => '' || '/Test/' => 'Test'
236 236
 			}
237 237
 			
238
-			if ($fileInfo->getMimetype () === OcrConstants::MIME_TYPE_PDF) {
238
+			if ($fileInfo->getMimetype() === OcrConstants::MIME_TYPE_PDF) {
239 239
 				// PDFs:
240
-				return \OCP\Files::buildNotExistingFileName ( $filePath, $fileName . '_OCR.pdf' );
240
+				return \OCP\Files::buildNotExistingFileName($filePath, $fileName . '_OCR.pdf');
241 241
 			} else {
242 242
 				// IMAGES:
243
-				return \OCP\Files::buildNotExistingFileName ( $filePath, $fileName . '_OCR.txt' );
243
+				return \OCP\Files::buildNotExistingFileName($filePath, $fileName . '_OCR.txt');
244 244
 			}
245
-		} catch ( Exception $e ) {
246
-			$this->handleException ( $e );
245
+		} catch (Exception $e) {
246
+			$this->handleException($e);
247 247
 		}
248 248
 	}
249 249
 	
@@ -260,32 +260,32 @@  discard block
 block discarded – undo
260 260
 	protected function buildTargetNotForShared(File $fileInfo) {
261 261
 		try {
262 262
 			// get rid of the .png or .pdf and so on
263
-			$fileName = substr ( $fileInfo->getName (), 0, (strrpos ( $fileInfo->getName (), '.' )) ); // 'thedom.png' => 'thedom'
263
+			$fileName = substr($fileInfo->getName(), 0, (strrpos($fileInfo->getName(), '.'))); // 'thedom.png' => 'thedom'
264 264
 			                                                                                           
265 265
 			// eliminate the file name from the path
266
-			$filePath = str_replace ( $fileInfo->getName (), '', $fileInfo->getPath () ); // 'files/Test/thedom.png' => 'files/Test/' || 'files/thedom.png' => 'files/'
266
+			$filePath = str_replace($fileInfo->getName(), '', $fileInfo->getPath()); // 'files/Test/thedom.png' => 'files/Test/' || 'files/thedom.png' => 'files/'
267 267
 			                                                                              
268 268
 			// and get the path on top of the files/ dir
269
-			$filePath = str_replace ( 'files', '', $filePath ); // 'files/Test/' => '/Test/' || 'files/' => '/'
269
+			$filePath = str_replace('files', '', $filePath); // 'files/Test/' => '/Test/' || 'files/' => '/'
270 270
 			                                                    
271 271
 			// remove the last slash
272
-			$filePath = substr_replace ( $filePath, '', strrpos ( $filePath, '/' ), strlen ( '/' ) ); // '/Test/' => '/Test' || '/' => ''
272
+			$filePath = substr_replace($filePath, '', strrpos($filePath, '/'), strlen('/')); // '/Test/' => '/Test' || '/' => ''
273 273
 			                                                                                          
274 274
 			// replace the first slash
275
-			$pos = strpos ( $filePath, '/' );
275
+			$pos = strpos($filePath, '/');
276 276
 			if ($pos !== false) {
277
-				$filePath = substr_replace ( $filePath, '', $pos, strlen ( '/' ) ); // '/Test' => '// 'Test' || '/' => ''
277
+				$filePath = substr_replace($filePath, '', $pos, strlen('/')); // '/Test' => '// 'Test' || '/' => ''
278 278
 			}
279 279
 			
280
-			if ($fileInfo->getMimetype () === OcrConstants::MIME_TYPE_PDF) {
280
+			if ($fileInfo->getMimetype() === OcrConstants::MIME_TYPE_PDF) {
281 281
 				// PDFs:
282
-				return \OCP\Files::buildNotExistingFileName ( $filePath, $fileName . '_OCR.pdf' );
282
+				return \OCP\Files::buildNotExistingFileName($filePath, $fileName . '_OCR.pdf');
283 283
 			} else {
284 284
 				// IMAGES:
285
-				return \OCP\Files::buildNotExistingFileName ( $filePath, $fileName . '_OCR.txt' );
285
+				return \OCP\Files::buildNotExistingFileName($filePath, $fileName . '_OCR.txt');
286 286
 			}
287
-		} catch ( Exception $e ) {
288
-			$this->handleException ( $e );
287
+		} catch (Exception $e) {
288
+			$this->handleException($e);
289 289
 		}
290 290
 	}
291 291
 	
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	private function checkMimeType(File $fileInfo) {
298 298
 		try {
299
-			if (! $fileInfo || ! in_array ( $fileInfo->getMimetype (), OcrConstants::ALLOWED_MIME_TYPES )) {
300
-				$this->logger->debug ( 'Getting FileInfo did not work or not included in the ALLOWED_MIMETYPES array.', [ 
299
+			if (!$fileInfo || !in_array($fileInfo->getMimetype(), OcrConstants::ALLOWED_MIME_TYPES)) {
300
+				$this->logger->debug('Getting FileInfo did not work or not included in the ALLOWED_MIMETYPES array.', [ 
301 301
 						'app' => 'ocr' 
302
-				] );
303
-				throw new NotFoundException ( $this->l10n->t ( 'Wrong MIME type.' ) );
302
+				]);
303
+				throw new NotFoundException($this->l10n->t('Wrong MIME type.'));
304 304
 			}
305
-		} catch ( Exception $e ) {
306
-			$this->handleException ( $e );
305
+		} catch (Exception $e) {
306
+			$this->handleException($e);
307 307
 		}
308 308
 	}
309 309
 	
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 	 * @throws NotFoundException
316 316
 	 */
317 317
 	private function handleException($e) {
318
-		$this->logger->logException ( $e, [ 
318
+		$this->logger->logException($e, [ 
319 319
 				'app' => 'ocr',
320 320
 				'message' => 'Exception during file service function processing' 
321
-		] );
321
+		]);
322 322
 		if ($e instanceof NotFoundException) {
323
-			throw new NotFoundException ( $e->getMessage () );
323
+			throw new NotFoundException($e->getMessage());
324 324
 		} else {
325 325
 			throw $e;
326 326
 		}
Please login to merge, or discard this patch.
lib/Service/StatusService.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function getStatus() {
82 82
 		try {
83 83
 			// returns user specific processed files
84
-			$processed = $this->jobMapper->findAllProcessed ( $this->userId );
85
-			$this->jobService->handleProcessed ();
84
+			$processed = $this->jobMapper->findAllProcessed($this->userId);
85
+			$this->jobService->handleProcessed();
86 86
 			
87 87
 			// return user specific pending state
88
-			$pending = $this->jobMapper->findAllPending ( $this->userId );
88
+			$pending = $this->jobMapper->findAllPending($this->userId);
89 89
 			
90 90
 			// return user specific failed state and set up error
91
-			$failed = $this->jobMapper->findAllFailed ( $this->userId );
92
-			$this->jobService->handleFailed ();
91
+			$failed = $this->jobMapper->findAllFailed($this->userId);
92
+			$this->jobService->handleFailed();
93 93
 			
94 94
 			return [ 
95
-					'processed' => count ( $processed ),
96
-					'failed' => count ( $failed ),
97
-					'pending' => count ( $pending ) 
95
+					'processed' => count($processed),
96
+					'failed' => count($failed),
97
+					'pending' => count($pending) 
98 98
 			];
99
-		} catch ( Exception $e ) {
100
-			$this->handleException ( $e );
99
+		} catch (Exception $e) {
100
+			$this->handleException($e);
101 101
 		}
102 102
 	}
103 103
 	
@@ -109,12 +109,12 @@  discard block
 block discarded – undo
109 109
 	 * @throws NotFoundException
110 110
 	 */
111 111
 	private function handleException($e) {
112
-		$this->logger->logException ( $e, [ 
112
+		$this->logger->logException($e, [ 
113 113
 				'app' => 'ocr',
114 114
 				'message' => 'Exception during status service function processing' 
115
-		] );
115
+		]);
116 116
 		if ($e instanceof NotFoundException) {
117
-			throw new NotFoundException ( $e->getMessage () );
117
+			throw new NotFoundException($e->getMessage());
118 118
 		} else {
119 119
 			throw $e;
120 120
 		}
Please login to merge, or discard this patch.
lib/Service/RedisService.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -75,24 +75,24 @@  discard block
 block discarded – undo
75 75
 	public function sendJob($job, $languages, $occDir) {
76 76
 		try {
77 77
 			// check for messaging and put everything together
78
-			$redis = $this->setupRedisInstance ();
78
+			$redis = $this->setupRedisInstance();
79 79
 			
80
-			$job = $this->mapper->insert ( $job );
81
-			$msg = json_encode ( array (
82
-					'id' => $job->getId (),
83
-					'type' => $job->getType (),
84
-					'source' => $job->getSource (),
85
-					'tempFile' => $job->getTempFile (),
80
+			$job = $this->mapper->insert($job);
81
+			$msg = json_encode(array(
82
+					'id' => $job->getId(),
83
+					'type' => $job->getType(),
84
+					'source' => $job->getSource(),
85
+					'tempFile' => $job->getTempFile(),
86 86
 					'languages' => $languages
87
-			) );
88
-			if (! $redis->lPush ( 'incoming', $msg )) {
89
-				throw new NotFoundException ( $this->l10n->t ( 'Could not add files to the redis OCR processing queue.' ) );
87
+			));
88
+			if (!$redis->lPush('incoming', $msg)) {
89
+				throw new NotFoundException($this->l10n->t('Could not add files to the redis OCR processing queue.'));
90 90
 			}
91
-		} catch ( Exception $e ) {
92
-			exec ( 'rm ' . $job->getTempFile () );
93
-			$job->setStatus ( 'FAILED' );
94
-			$this->mapper->update ( $job );
95
-			$this->handleException ( $e );
91
+		} catch (Exception $e) {
92
+			exec('rm ' . $job->getTempFile());
93
+			$job->setStatus('FAILED');
94
+			$this->mapper->update($job);
95
+			$this->handleException($e);
96 96
 		}
97 97
 	}
98 98
 	
@@ -105,28 +105,28 @@  discard block
 block discarded – undo
105 105
 	 * @return \Redis
106 106
 	 */
107 107
 	private function setupRedisInstance() {
108
-		if (! extension_loaded ( 'redis' )) {
109
-			$this->logger->debug ( 'It seems that the message queueing capabilities are not available in your local php installation. Please install php-redis.', [ 
108
+		if (!extension_loaded('redis')) {
109
+			$this->logger->debug('It seems that the message queueing capabilities are not available in your local php installation. Please install php-redis.', [ 
110 110
 					'app' => 'ocr' 
111
-			] );
112
-			throw new NotFoundException ( $this->l10n->t ( 'Message queueing capabilities are missing on the server.' ) );
111
+			]);
112
+			throw new NotFoundException($this->l10n->t('Message queueing capabilities are missing on the server.'));
113 113
 		}
114 114
 		
115
-		$redis = new \Redis ();
115
+		$redis = new \Redis();
116 116
 		// TODO: get from config
117
-		if (! $redis->connect ( '127.0.0.1', 6379, 2.5, NULL, 100 )) {
118
-			$this->logger->debug ( 'Cannot connect to Redis.', [ 
117
+		if (!$redis->connect('127.0.0.1', 6379, 2.5, NULL, 100)) {
118
+			$this->logger->debug('Cannot connect to Redis.', [ 
119 119
 					'app' => 'ocr' 
120
-			] );
121
-			throw new NotFoundException ( $this->l10n->t ( 'Cannot connect to Redis.' ) );
120
+			]);
121
+			throw new NotFoundException($this->l10n->t('Cannot connect to Redis.'));
122 122
 		}
123
-		if (! $redis->select ( 0 )) {
124
-			$this->logger->debug ( 'Cannot connect to the right Redis database.', [
123
+		if (!$redis->select(0)) {
124
+			$this->logger->debug('Cannot connect to the right Redis database.', [
125 125
 					'app' => 'ocr'
126
-			] );
127
-			throw new NotFoundException ( $this->l10n->t ( 'Cannot connect to the right Redis database.' ) );
126
+			]);
127
+			throw new NotFoundException($this->l10n->t('Cannot connect to the right Redis database.'));
128 128
 		}
129
-		$redis->setOption ( \Redis::OPT_PREFIX, 'ocr:' );
129
+		$redis->setOption(\Redis::OPT_PREFIX, 'ocr:');
130 130
 		
131 131
 		return $redis;
132 132
 	}
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 	 * @throws NotFoundException
140 140
 	 */
141 141
 	private function handleException($e) {
142
-		$this->logger->logException ( $e, [ 
142
+		$this->logger->logException($e, [ 
143 143
 				'app' => 'ocr',
144 144
 				'message' => 'Exception during message queue processing' 
145
-		] );
145
+		]);
146 146
 		if ($e instanceof NotFoundException) {
147
-			throw new NotFoundException ( $e->getMessage () );
147
+			throw new NotFoundException($e->getMessage());
148 148
 		} else {
149 149
 			throw $e;
150 150
 		}
Please login to merge, or discard this patch.