Passed
Pull Request — master (#451)
by korelstar
07:41
created
lib/Service/NotesService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	public function update($id, $content, $userId, $category = null, $mtime = 0) : Note {
165 165
 		$notesFolder = $this->getFolderForUser($userId);
166 166
 		$file = $this->getFileById($notesFolder, $id);
167
-		$title = $this->noteUtil->getSafeTitleFromContent($content===null ? $file->getContent() : $content);
167
+		$title = $this->noteUtil->getSafeTitleFromContent($content === null ? $file->getContent() : $content);
168 168
 
169 169
 		// rename/move file with respect to title/category
170 170
 		// this can fail if access rights are not sufficient or category name is illegal
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	private function getFolderForUser($userId) : Folder {
251 251
 		// TODO use IRootFolder->getUserFolder()  ?
252
-		$path = '/' . $userId . '/files/' . $this->settings->get($userId, 'notesPath');
252
+		$path = '/'.$userId.'/files/'.$this->settings->get($userId, 'notesPath');
253 253
 		try {
254 254
 			$folder = $this->noteUtil->getOrCreateFolder($path);
255 255
 		} catch (\Exception $e) {
Please login to merge, or discard this patch.
lib/Service/NoteUtil.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		$id = $file->getId();
70 70
 		$currentFilePath = $this->root->getFullPath($file->getPath());
71 71
 		$currentBasePath = pathinfo($currentFilePath, PATHINFO_DIRNAME);
72
-		$fileSuffix = '.' . pathinfo($file->getName(), PATHINFO_EXTENSION);
72
+		$fileSuffix = '.'.pathinfo($file->getName(), PATHINFO_EXTENSION);
73 73
 
74 74
 		// detect (new) folder path based on category name
75
-		if ($category===null) {
75
+		if ($category === null) {
76 76
 			$basePath = $currentBasePath;
77 77
 		} else {
78 78
 			$basePath = $notesFolder->getPath();
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 				// sanitise path
81 81
 				$cats = explode('/', $category);
82 82
 				$cats = array_map([$this, 'sanitisePath'], $cats);
83
-				$cats = array_filter($cats, function ($str) {
83
+				$cats = array_filter($cats, function($str) {
84 84
 					return !empty($str);
85 85
 				});
86 86
 				$basePath .= '/'.implode('/', $cats);
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$folder = $this->getOrCreateFolder($basePath);
90 90
 
91 91
 		// assemble new file path
92
-		$newFilePath = $basePath . '/' . $this->generateFileName($folder, $title, $fileSuffix, $id);
92
+		$newFilePath = $basePath.'/'.$this->generateFileName($folder, $title, $fileSuffix, $id);
93 93
 
94 94
 		// if the current path is not the new path, the file has to be renamed
95 95
 		if ($currentFilePath !== $newFilePath) {
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * files with the same title
115 115
 	 */
116 116
 	public function generateFileName(Folder $folder, string $title, string $suffix, int $id) : string {
117
-		$path = $title . $suffix;
117
+		$path = $title.$suffix;
118 118
 
119 119
 		// if file does not exist, that name has not been taken. Similar we don't
120 120
 		// need to handle file collisions if it is the filename did not change
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 				$newId = ((int) $matches['id']) + 1;
128 128
 				$newTitle = preg_replace(
129 129
 					'/(.*)\s\((\d+)\)$/u',
130
-					'$1 (' . $newId . ')',
130
+					'$1 ('.$newId.')',
131 131
 					$title
132 132
 				);
133 133
 			} else {
134
-				$newTitle = $title . ' (2)';
134
+				$newTitle = $title.' (2)';
135 135
 			}
136 136
 			return $this->generateFileName($folder, $newTitle, $suffix, $id);
137 137
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	public function deleteEmptyFolder(Folder $notesFolder, Folder $folder) {
210 210
 		$content = $folder->getDirectoryListing();
211 211
 		$isEmpty = !count($content);
212
-		$isNotesFolder = $folder->getPath()===$notesFolder->getPath();
212
+		$isNotesFolder = $folder->getPath() === $notesFolder->getPath();
213 213
 		if ($isEmpty && !$isNotesFolder) {
214 214
 			$this->logger->info('Deleting empty category folder '.$folder->getPath(), ['app' => $this->appName]);
215 215
 			$parent = $folder->getParent();
Please login to merge, or discard this patch.
lib/Controller/NotesApiController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$metas = $this->metaService->updateAll($this->getUID(), $notes);
87 87
 		foreach ($notes as $note) {
88 88
 			$lastUpdate = $metas[$note->getId()]->getLastUpdate();
89
-			if ($pruneBefore && $lastUpdate<$pruneBefore) {
89
+			if ($pruneBefore && $lastUpdate < $pruneBefore) {
90 90
 				$vars = get_object_vars($note);
91 91
 				unset($vars['id']);
92 92
 				$this->excludeFields($note, array_keys($vars));
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 	 * @return Note
186 186
 	 */
187 187
 	private function updateData($id, $content, $category, $modified, $favorite) {
188
-		if ($favorite!==null) {
188
+		if ($favorite !== null) {
189 189
 			$this->service->favorite($id, $favorite, $this->getUID());
190 190
 		}
191
-		if ($content===null) {
191
+		if ($content === null) {
192 192
 			return $this->service->get($id, $this->getUID());
193 193
 		} else {
194 194
 			return $this->service->update($id, $content, $this->getUID(), $category, $modified);
Please login to merge, or discard this patch.