Provider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 17
ccs 0
cts 8
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A search() 0 8 2
1
<?php
2
3
/**
4
 * ownCloud
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
8
 * License as published by the Free Software Foundation; either
9
 * version 3 of the License, or any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public
17
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
 */
20
21
namespace OCA\Contacts\Search;
22
23
/**
24
 * The updated contacts search provider
25
 */
26
class Provider extends \OCP\Search\Provider {
27
28
	/**
29
	 * Search for contacts
30
	 *
31
	 * @param string $query
32
	 * @return array list of \OCA\Calendar\Search\Contact
33
	 */
34
	function search($query) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style Naming introduced by
The variable $_results is not named in camelCase.

This check marks variable names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style Naming introduced by
The variable $_result is not named in camelCase.

This check marks variable names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for search.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
35
		$_results = \OCP\Contacts::search($query, array('N', 'FN', 'EMAIL', 'NICKNAME', 'ORG'));
36
		$results = array();
37
		foreach ($_results as $_result) {
38
			$results[] = new \OCA\Contacts\Search\Contact($_result);
39
		}
40
		return $results;
41
	}
42
}
43