Passed
Push — master ( 132686...15561b )
by Morris
20:00 queued 09:08
created
lib/private/Collaboration/Collaborators/Search.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -33,78 +33,78 @@
 block discarded – undo
33 33
 use OCP\Share;
34 34
 
35 35
 class Search implements ISearch {
36
-	/** @var IContainer */
37
-	private $c;
36
+    /** @var IContainer */
37
+    private $c;
38 38
 
39
-	protected $pluginList = [];
39
+    protected $pluginList = [];
40 40
 
41
-	public function __construct(IContainer $c) {
42
-		$this->c = $c;
43
-	}
41
+    public function __construct(IContainer $c) {
42
+        $this->c = $c;
43
+    }
44 44
 
45
-	/**
46
-	 * @param string $search
47
-	 * @param array $shareTypes
48
-	 * @param bool $lookup
49
-	 * @param int|null $limit
50
-	 * @param int|null $offset
51
-	 * @return array
52
-	 * @throws \OCP\AppFramework\QueryException
53
-	 */
54
-	public function search($search, array $shareTypes, $lookup, $limit, $offset) {
55
-		$hasMoreResults = false;
45
+    /**
46
+     * @param string $search
47
+     * @param array $shareTypes
48
+     * @param bool $lookup
49
+     * @param int|null $limit
50
+     * @param int|null $offset
51
+     * @return array
52
+     * @throws \OCP\AppFramework\QueryException
53
+     */
54
+    public function search($search, array $shareTypes, $lookup, $limit, $offset) {
55
+        $hasMoreResults = false;
56 56
 
57
-		// Trim leading and trailing whitespace characters, e.g. when query is copy-pasted
58
-		$search = trim($search);
57
+        // Trim leading and trailing whitespace characters, e.g. when query is copy-pasted
58
+        $search = trim($search);
59 59
 
60
-		/** @var ISearchResult $searchResult */
61
-		$searchResult = $this->c->resolve(SearchResult::class);
60
+        /** @var ISearchResult $searchResult */
61
+        $searchResult = $this->c->resolve(SearchResult::class);
62 62
 
63
-		foreach ($shareTypes as $type) {
64
-			if (!isset($this->pluginList[$type])) {
65
-				continue;
66
-			}
67
-			foreach ($this->pluginList[$type] as $plugin) {
68
-				/** @var ISearchPlugin $searchPlugin */
69
-				$searchPlugin = $this->c->resolve($plugin);
70
-				$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
71
-			}
72
-		}
63
+        foreach ($shareTypes as $type) {
64
+            if (!isset($this->pluginList[$type])) {
65
+                continue;
66
+            }
67
+            foreach ($this->pluginList[$type] as $plugin) {
68
+                /** @var ISearchPlugin $searchPlugin */
69
+                $searchPlugin = $this->c->resolve($plugin);
70
+                $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
71
+            }
72
+        }
73 73
 
74
-		// Get from lookup server, not a separate share type
75
-		if ($lookup) {
76
-			$searchPlugin = $this->c->resolve(LookupPlugin::class);
77
-			$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
78
-		}
74
+        // Get from lookup server, not a separate share type
75
+        if ($lookup) {
76
+            $searchPlugin = $this->c->resolve(LookupPlugin::class);
77
+            $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
78
+        }
79 79
 
80
-		// sanitizing, could go into the plugins as well
80
+        // sanitizing, could go into the plugins as well
81 81
 
82
-		// if we have a exact match, either for the federated cloud id or for the
83
-		// email address we only return the exact match. It is highly unlikely
84
-		// that the exact same email address and federated cloud id exists
85
-		$emailType = new SearchResultType('emails');
86
-		$remoteType = new SearchResultType('remotes');
87
-		if ($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
88
-			$searchResult->unsetResult($remoteType);
89
-		} elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
90
-			$searchResult->unsetResult($emailType);
91
-		}
82
+        // if we have a exact match, either for the federated cloud id or for the
83
+        // email address we only return the exact match. It is highly unlikely
84
+        // that the exact same email address and federated cloud id exists
85
+        $emailType = new SearchResultType('emails');
86
+        $remoteType = new SearchResultType('remotes');
87
+        if ($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
88
+            $searchResult->unsetResult($remoteType);
89
+        } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
90
+            $searchResult->unsetResult($emailType);
91
+        }
92 92
 
93
-		// if we have an exact local user match, there is no need to show the remote and email matches
94
-		$userType = new SearchResultType('users');
95
-		if ($searchResult->hasExactIdMatch($userType)) {
96
-			$searchResult->unsetResult($remoteType);
97
-			$searchResult->unsetResult($emailType);
98
-		}
93
+        // if we have an exact local user match, there is no need to show the remote and email matches
94
+        $userType = new SearchResultType('users');
95
+        if ($searchResult->hasExactIdMatch($userType)) {
96
+            $searchResult->unsetResult($remoteType);
97
+            $searchResult->unsetResult($emailType);
98
+        }
99 99
 
100
-		return [$searchResult->asArray(), (bool)$hasMoreResults];
101
-	}
100
+        return [$searchResult->asArray(), (bool)$hasMoreResults];
101
+    }
102 102
 
103
-	public function registerPlugin(array $pluginInfo) {
104
-		$shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
105
-		if ($shareType === null) {
106
-			throw new \InvalidArgumentException('Provided ShareType is invalid');
107
-		}
108
-		$this->pluginList[$shareType][] = $pluginInfo['class'];
109
-	}
103
+    public function registerPlugin(array $pluginInfo) {
104
+        $shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
105
+        if ($shareType === null) {
106
+            throw new \InvalidArgumentException('Provided ShareType is invalid');
107
+        }
108
+        $this->pluginList[$shareType][] = $pluginInfo['class'];
109
+    }
110 110
 }
Please login to merge, or discard this patch.