Passed
Pull Request — master (#451)
by korelstar
02:44
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 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/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
 	private const TAG_FAVORITE = \OC\Tags::TAG_FAVORITE; // @phan-suppress-current-line PhanUndeclaredClassConstant
42 42
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$note = new static();
54 54
 		$note->initCommonBaseFields($file, $notesFolder, $tags);
55 55
 		if (!$onlyMeta) {
56
-			$fileContent=$file->getContent();
56
+			$fileContent = $file->getContent();
57 57
 			$note->setContent(self::convertEncoding($fileContent));
58 58
 		}
59 59
 		if (!$onlyMeta) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		$this->setId($file->getId());
89 89
 		$this->setTitle(pathinfo($file->getName(), PATHINFO_FILENAME)); // remove extension
90 90
 		$this->setModified($file->getMTime());
91
-		$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1);
91
+		$subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath()) + 1);
92 92
 		$this->setCategory($subdir ? $subdir : '');
93 93
 		if (is_array($tags) && in_array(self::TAG_FAVORITE, $tags)) {
94 94
 			$this->setFavorite(true);
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		// collect all relevant attributes
101 101
 		$data = '';
102 102
 		foreach (get_object_vars($this) as $key => $val) {
103
-			if ($key!=='etag') {
103
+			if ($key !== 'etag') {
104 104
 				$data .= $val;
105 105
 			}
106 106
 		}
Please login to merge, or discard this patch.