GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Nip_Helper_Fulltext   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 63
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0
wmc 12
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
C buildString() 0 34 8
A matchNumbers() 0 10 2
A instance() 0 7 2
1
<?php
2
3
/**
4
 * Nip Framework
5
 *
6
 * @category   Nip
7
 * @copyright  2009 Nip Framework
8
 * @license    http://www.opensource.org/licenses/mit-license.php The MIT License
9
 * @version    SVN: $Id: Fulltext.php 14 2009-04-13 11:24:22Z victor.stanciu $
10
 */
11
12
class Nip_Helper_Fulltext extends Nip\Helpers\AbstractHelper {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
13
14
	public function buildString($keywords, $mode = 'any') {
15
		$return = "";
16
17
		$keywords = explode(" ", $keywords);
18
19
		switch ($mode) {
20
			case "any":
21
				foreach ($keywords as $item) {
22
					$return .= $this->matchNumbers($item).'* ';
23
				}
24
			break;
25
26
			case "all":
27
				if (count($keywords) == 1) {
28
					$return .=  $this->matchNumbers(reset($keywords)).'* ';
29
				} else {
30
					foreach ($keywords as $item) {
31
						$return .= '+'. $this->matchNumbers($item).'* ';
32
					}
33
				}
34
35
			break;
36
				case "exact":
37
				foreach ($keywords as $item) {
38
					$return .= $this->matchNumbers($item).' ';
39
				}
40
				$return = '+"'.$return.'"';
41
			break;
42
		}
43
44
		$return = strtolower(trim($return));
45
46
		return $return;
47
	}
48
49
50
	private function matchNumbers($input) {
51
		$stripped = array("%", ",", ".");
52
		$replaced = array("__", "_", "_");
53
54
		if (is_numeric(str_replace($stripped, "", $input))) {
55
			return str_replace($stripped, $replaced, $input);
56
		} else {
57
			return $input;
58
		}
59
	}
60
61
62
	/**
63
	 * Returns singleton instance
64
	 *
65
	 * @return Nip_Helper_Fulltext
66
	 */
67
	static public function instance() {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
68
		static $instance;
69
		if (!($instance instanceof self)) {
70
			$instance = new self();
71
		}
72
		return $instance;
73
	}
74
}