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