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::matchNumbers()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 10
ccs 0
cts 6
cp 0
crap 6
rs 9.4285
c 0
b 0
f 0
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
}