Completed
Pull Request — master (#6779)
by Blizzz
15:12
created
apps/comments/lib/Collaboration/CommentersSorter.php 2 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -29,65 +29,65 @@
 block discarded – undo
29 29
 
30 30
 class CommentersSorter implements ISorter {
31 31
 
32
-	/** @var ICommentsManager */
33
-	private $commentsManager;
34
-
35
-	public function __construct(ICommentsManager $commentsManager) {
36
-		$this->commentsManager = $commentsManager;
37
-	}
38
-
39
-	public function getId() {
40
-		return 'commenters';
41
-	}
42
-
43
-	/**
44
-	 * Sorts people who commented on the given item atop (descelating) of the
45
-	 * others
46
-	 *
47
-	 * @param array $sortArray
48
-	 * @param array $context
49
-	 */
50
-	public function sort(array &$sortArray, array $context) {
51
-		$commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
52
-		if(count($commenters) === 0) {
53
-			return;
54
-		}
55
-
56
-		foreach ($sortArray as $type => &$byType) {
57
-			if(!isset($commenters[$type])) {
58
-				continue;
59
-			}
60
-
61
-			usort($byType, function ($a, $b) use ($commenters, $type) {
62
-				$r = $this->compare($a, $b, $commenters[$type]);
63
-				return $r;
64
-			});
65
-
66
-			$s = '';
67
-		}
68
-	}
69
-
70
-	/**
71
-	 * @param $type
72
-	 * @param $id
73
-	 * @return array
74
-	 */
75
-	protected function retrieveCommentsInformation($type, $id) {
76
-		$comments = $this->commentsManager->getForObject($type, $id, 1);
77
-		if(count($comments) === 0) {
78
-			return [];
79
-		}
80
-
81
-		return $this->commentsManager->getActorsInTree($comments[0]->getTopmostParentId());
82
-	}
83
-
84
-	protected function compare(array $a, array $b, array $commenters) {
85
-		$a = $a['value']['shareWith'];
86
-		$b = $b['value']['shareWith'];
87
-
88
-		$valueA = isset($commenters[$a]) ? $commenters[$a] : 0;
89
-		$valueB = isset($commenters[$b]) ? $commenters[$b] : 0;
90
-
91
-		return $valueB - $valueA;
92
-	}
32
+    /** @var ICommentsManager */
33
+    private $commentsManager;
34
+
35
+    public function __construct(ICommentsManager $commentsManager) {
36
+        $this->commentsManager = $commentsManager;
37
+    }
38
+
39
+    public function getId() {
40
+        return 'commenters';
41
+    }
42
+
43
+    /**
44
+     * Sorts people who commented on the given item atop (descelating) of the
45
+     * others
46
+     *
47
+     * @param array $sortArray
48
+     * @param array $context
49
+     */
50
+    public function sort(array &$sortArray, array $context) {
51
+        $commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
52
+        if(count($commenters) === 0) {
53
+            return;
54
+        }
55
+
56
+        foreach ($sortArray as $type => &$byType) {
57
+            if(!isset($commenters[$type])) {
58
+                continue;
59
+            }
60
+
61
+            usort($byType, function ($a, $b) use ($commenters, $type) {
62
+                $r = $this->compare($a, $b, $commenters[$type]);
63
+                return $r;
64
+            });
65
+
66
+            $s = '';
67
+        }
68
+    }
69
+
70
+    /**
71
+     * @param $type
72
+     * @param $id
73
+     * @return array
74
+     */
75
+    protected function retrieveCommentsInformation($type, $id) {
76
+        $comments = $this->commentsManager->getForObject($type, $id, 1);
77
+        if(count($comments) === 0) {
78
+            return [];
79
+        }
80
+
81
+        return $this->commentsManager->getActorsInTree($comments[0]->getTopmostParentId());
82
+    }
83
+
84
+    protected function compare(array $a, array $b, array $commenters) {
85
+        $a = $a['value']['shareWith'];
86
+        $b = $b['value']['shareWith'];
87
+
88
+        $valueA = isset($commenters[$a]) ? $commenters[$a] : 0;
89
+        $valueB = isset($commenters[$b]) ? $commenters[$b] : 0;
90
+
91
+        return $valueB - $valueA;
92
+    }
93 93
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public function sort(array &$sortArray, array $context) {
51 51
 		$commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
52
-		if(count($commenters) === 0) {
52
+		if (count($commenters) === 0) {
53 53
 			return;
54 54
 		}
55 55
 
56 56
 		foreach ($sortArray as $type => &$byType) {
57
-			if(!isset($commenters[$type])) {
57
+			if (!isset($commenters[$type])) {
58 58
 				continue;
59 59
 			}
60 60
 
61
-			usort($byType, function ($a, $b) use ($commenters, $type) {
61
+			usort($byType, function($a, $b) use ($commenters, $type) {
62 62
 				$r = $this->compare($a, $b, $commenters[$type]);
63 63
 				return $r;
64 64
 			});
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	protected function retrieveCommentsInformation($type, $id) {
76 76
 		$comments = $this->commentsManager->getForObject($type, $id, 1);
77
-		if(count($comments) === 0) {
77
+		if (count($comments) === 0) {
78 78
 			return [];
79 79
 		}
80 80
 
Please login to merge, or discard this patch.
apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php 2 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -31,55 +31,55 @@
 block discarded – undo
31 31
 
32 32
 class ShareRecipientSorter implements ISorter {
33 33
 
34
-	/** @var IManager */
35
-	private $shareManager;
36
-	/** @var Folder */
37
-	private $userFolder;
34
+    /** @var IManager */
35
+    private $shareManager;
36
+    /** @var Folder */
37
+    private $userFolder;
38 38
 
39
-	public function __construct(IManager $shareManager, Folder $userFolder) {
40
-		$this->shareManager = $shareManager;
41
-		$this->userFolder = $userFolder;
42
-	}
39
+    public function __construct(IManager $shareManager, Folder $userFolder) {
40
+        $this->shareManager = $shareManager;
41
+        $this->userFolder = $userFolder;
42
+    }
43 43
 
44
-	public function getId() {
45
-		return 'share-recipients';
46
-	}
44
+    public function getId() {
45
+        return 'share-recipients';
46
+    }
47 47
 
48
-	public function sort(array &$sortArray, array $context) {
49
-		// let's be tolerant. Comments  uses "files" by default, other usages are often singular
50
-		if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
51
-			return;
52
-		}
53
-		/** @var Node[] $nodes */
54
-		$nodes = $this->userFolder->getById((int)$context['itemId']);
55
-		if(count($nodes) === 0) {
56
-			return;
57
-		}
58
-		$al = $this->shareManager->getAccessList($nodes[0]);
48
+    public function sort(array &$sortArray, array $context) {
49
+        // let's be tolerant. Comments  uses "files" by default, other usages are often singular
50
+        if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
51
+            return;
52
+        }
53
+        /** @var Node[] $nodes */
54
+        $nodes = $this->userFolder->getById((int)$context['itemId']);
55
+        if(count($nodes) === 0) {
56
+            return;
57
+        }
58
+        $al = $this->shareManager->getAccessList($nodes[0]);
59 59
 
60
-		foreach ($sortArray as $type => &$byType) {
61
-			if(!isset($al[$type]) || !is_array($al[$type])) {
62
-				continue;
63
-			}
64
-			usort($byType, function ($a, $b) use ($al, $type) {
65
-				return  $this->compare($a, $b, $al[$type]);
66
-			});
67
-		}
68
-	}
60
+        foreach ($sortArray as $type => &$byType) {
61
+            if(!isset($al[$type]) || !is_array($al[$type])) {
62
+                continue;
63
+            }
64
+            usort($byType, function ($a, $b) use ($al, $type) {
65
+                return  $this->compare($a, $b, $al[$type]);
66
+            });
67
+        }
68
+    }
69 69
 
70
-	/**
71
-	 * @param array $a
72
-	 * @param array $b
73
-	 * @param array $al
74
-	 * @return int
75
-	 */
76
-	protected function compare(array $a, array $b, array $al) {
77
-		$a = $a['value']['shareWith'];
78
-		$b = $b['value']['shareWith'];
70
+    /**
71
+     * @param array $a
72
+     * @param array $b
73
+     * @param array $al
74
+     * @return int
75
+     */
76
+    protected function compare(array $a, array $b, array $al) {
77
+        $a = $a['value']['shareWith'];
78
+        $b = $b['value']['shareWith'];
79 79
 
80
-		$valueA = (int)in_array($a, $al, true);
81
-		$valueB = (int)in_array($b, $al, true);
80
+        $valueA = (int)in_array($a, $al, true);
81
+        $valueB = (int)in_array($b, $al, true);
82 82
 
83
-		return $valueB - $valueA;
84
-	}
83
+        return $valueB - $valueA;
84
+    }
85 85
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
 
48 48
 	public function sort(array &$sortArray, array $context) {
49 49
 		// let's be tolerant. Comments  uses "files" by default, other usages are often singular
50
-		if($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
50
+		if ($context['itemType'] !== 'files' && $context['itemType'] !== 'file') {
51 51
 			return;
52 52
 		}
53 53
 		/** @var Node[] $nodes */
54
-		$nodes = $this->userFolder->getById((int)$context['itemId']);
55
-		if(count($nodes) === 0) {
54
+		$nodes = $this->userFolder->getById((int) $context['itemId']);
55
+		if (count($nodes) === 0) {
56 56
 			return;
57 57
 		}
58 58
 		$al = $this->shareManager->getAccessList($nodes[0]);
59 59
 
60 60
 		foreach ($sortArray as $type => &$byType) {
61
-			if(!isset($al[$type]) || !is_array($al[$type])) {
61
+			if (!isset($al[$type]) || !is_array($al[$type])) {
62 62
 				continue;
63 63
 			}
64
-			usort($byType, function ($a, $b) use ($al, $type) {
64
+			usort($byType, function($a, $b) use ($al, $type) {
65 65
 				return  $this->compare($a, $b, $al[$type]);
66 66
 			});
67 67
 		}
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 		$a = $a['value']['shareWith'];
78 78
 		$b = $b['value']['shareWith'];
79 79
 
80
-		$valueA = (int)in_array($a, $al, true);
81
-		$valueB = (int)in_array($b, $al, true);
80
+		$valueA = (int) in_array($a, $al, true);
81
+		$valueB = (int) in_array($b, $al, true);
82 82
 
83 83
 		return $valueB - $valueA;
84 84
 	}
Please login to merge, or discard this patch.