Passed
Pull Request — master (#451)
by korelstar
02:57
created
lib/Service/SettingsService.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 				}
55 55
 			}
56 56
 		} else {
57
-			$settings = (object)$this->defaults;
57
+			$settings = (object) $this->defaults;
58 58
 		}
59 59
 		return $settings;
60 60
 	}
Please login to merge, or discard this patch.
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/MetaService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 			if (!array_key_exists($id, $metas)) {
35 35
 				// INSERT new notes
36 36
 				$metas[$note->getId()] = $this->create($userId, $note);
37
-			} elseif ($note->getEtag()!==$metas[$id]->getEtag()) {
37
+			} elseif ($note->getEtag() !== $metas[$id]->getEtag()) {
38 38
 				// UPDATE changed notes
39 39
 				$meta = $metas[$id];
40 40
 				$this->updateIfNeeded($meta, $note);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	private function updateIfNeeded(&$meta, $note) {
63
-		if ($note->getEtag()!==$meta->getEtag()) {
63
+		if ($note->getEtag() !== $meta->getEtag()) {
64 64
 			$meta->setEtag($note->getEtag());
65 65
 			$meta->setLastUpdate(time());
66 66
 			$this->metaMapper->update($meta);
Please login to merge, or discard this patch.
lib/Service/NoteUtil.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 		$id = $file->getId();
72 72
 		$currentFilePath = $this->root->getFullPath($file->getPath());
73 73
 		$currentBasePath = pathinfo($currentFilePath, PATHINFO_DIRNAME);
74
-		$fileSuffix = '.' . pathinfo($file->getName(), PATHINFO_EXTENSION);
74
+		$fileSuffix = '.'.pathinfo($file->getName(), PATHINFO_EXTENSION);
75 75
 
76 76
 		// detect (new) folder path based on category name
77
-		if ($category===null) {
77
+		if ($category === null) {
78 78
 			$basePath = $currentBasePath;
79 79
 		} else {
80 80
 			$basePath = $notesFolder->getPath();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 				// sanitise path
83 83
 				$cats = explode('/', $category);
84 84
 				$cats = array_map([$this, 'sanitisePath'], $cats);
85
-				$cats = array_filter($cats, function ($str) {
85
+				$cats = array_filter($cats, function($str) {
86 86
 					return !empty($str);
87 87
 				});
88 88
 				$basePath .= '/'.implode('/', $cats);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		$folder = $this->getOrCreateFolder($basePath);
92 92
 
93 93
 		// assemble new file path
94
-		$newFilePath = $basePath . '/' . $this->generateFileName($folder, $title, $fileSuffix, $id);
94
+		$newFilePath = $basePath.'/'.$this->generateFileName($folder, $title, $fileSuffix, $id);
95 95
 
96 96
 		// if the current path is not the new path, the file has to be renamed
97 97
 		if ($currentFilePath !== $newFilePath) {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		}
100 100
 		if ($currentBasePath !== $basePath) {
101 101
 			FileInfo $fileBasePath = $this->root->get($currentBasePath);
102
-			if($fileBasePath instanceof Folder)
102
+			if ($fileBasePath instanceof Folder)
103 103
 			$this->deleteEmptyFolder($notesFolder, $fileBasePath);
104 104
 		}
105 105
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * files with the same title
119 119
 	 */
120 120
 	public function generateFileName(Folder $folder, string $title, string $suffix, int $id) : string {
121
-		$path = $title . $suffix;
121
+		$path = $title.$suffix;
122 122
 
123 123
 		// if file does not exist, that name has not been taken. Similar we don't
124 124
 		// need to handle file collisions if it is the filename did not change
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 				$newId = ((int) $matches['id']) + 1;
132 132
 				$newTitle = preg_replace(
133 133
 					'/(.*)\s\((\d+)\)$/u',
134
-					'$1 (' . $newId . ')',
134
+					'$1 ('.$newId.')',
135 135
 					$title
136 136
 				);
137 137
 			} else {
138
-				$newTitle = $title . ' (2)';
138
+				$newTitle = $title.' (2)';
139 139
 			}
140 140
 			return $this->generateFileName($folder, $newTitle, $suffix, $id);
141 141
 		}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	public function deleteEmptyFolder(Folder $notesFolder, Folder $folder) {
214 214
 		$content = $folder->getDirectoryListing();
215 215
 		$isEmpty = !count($content);
216
-		$isNotesFolder = $folder->getPath()===$notesFolder->getPath();
216
+		$isNotesFolder = $folder->getPath() === $notesFolder->getPath();
217 217
 		if ($isEmpty && !$isNotesFolder) {
218 218
 			$this->logger->info('Deleting empty category folder '.$folder->getPath(), ['app' => $this->appName]);
219 219
 			$parent = $folder->getParent();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,8 +99,9 @@
 block discarded – undo
99 99
 		}
100 100
 		if ($currentBasePath !== $basePath) {
101 101
 			FileInfo $fileBasePath = $this->root->get($currentBasePath);
102
-			if($fileBasePath instanceof Folder)
103
-			$this->deleteEmptyFolder($notesFolder, $fileBasePath);
102
+			if($fileBasePath instanceof Folder) {
103
+						$this->deleteEmptyFolder($notesFolder, $fileBasePath);
104
+			}
104 105
 		}
105 106
 	}
106 107
 
Please login to merge, or discard this patch.
lib/Db/Note.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	public $content = null;
37 37
 	public $favorite = false;
38 38
 	public $error = false;
39
-	public $errorMessage='';
39
+	public $errorMessage = '';
40 40
 
41 41
 	public function __construct() {
42 42
 		$this->addType('modified', 'integer');
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$note = new static();
52 52
 		$note->initCommonBaseFields($file, $notesFolder, $tags);
53 53
 		if (!$onlyMeta) {
54
-			$fileContent=$file->getContent();
54
+			$fileContent = $file->getContent();
55 55
 			$note->setContent(self::convertEncoding($fileContent));
56 56
 		}
57 57
 		if (!$onlyMeta) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$this->setId($file->getId());
87 87
 		$this->setTitle(pathinfo($file->getName(), PATHINFO_FILENAME)); // remove extension
88 88
 		$this->setModified($file->getMTime());
89
-		$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1);
89
+		$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath()) + 1);
90 90
 		$this->setCategory($subdir ? $subdir : '');
91 91
 		if (is_array($tags) && in_array(\OC\Tags::TAG_FAVORITE, $tags)) {
92 92
 			$this->setFavorite(true);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		// collect all relevant attributes
99 99
 		$data = '';
100 100
 		foreach (get_object_vars($this) as $key => $val) {
101
-			if ($key!=='etag') {
101
+			if ($key !== 'etag') {
102 102
 				$data .= $val;
103 103
 			}
104 104
 		}
Please login to merge, or discard this patch.