Completed
Push — master ( d9189f...847185 )
by Jean-Christophe
03:54
created

JString   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 17
lcom 0
cbo 0
dl 0
loc 36
rs 10
c 2
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A contains() 0 3 1
A startswith() 0 3 1
A endswith() 0 3 1
A isNull() 0 3 3
A isNotNull() 0 3 3
A isBoolean() 0 3 3
A isBooleanTrue() 0 3 2
A isBooleanFalse() 0 3 2
A camelCaseToSeparated() 0 3 1
1
<?php
2
namespace Ajax\service;
3
class JString {
4
5
	public static function contains($hay,$needle){
6
		return strpos($hay, $needle) !== false;
7
	}
8
	public static function startswith($hay, $needle) {
9
		return substr($hay, 0, strlen($needle)) === $needle;
10
	}
11
12
	public static function endswith($hay, $needle) {
13
		return substr($hay, -strlen($needle)) === $needle;
14
	}
15
16
	public static function isNull($s){
17
		return (!isset($s) || NULL===$s || ""===$s);
18
	}
19
	public static function isNotNull($s){
20
		return (isset($s) && NULL!==$s && ""!==$s);
21
	}
22
23
	public static function isBoolean($value){
24
		return \is_bool($value) || $value==1 || $value==0;
25
	}
26
27
	public static function isBooleanTrue($value){
28
		return $value==1 || $value;
29
	}
30
31
	public static function isBooleanFalse($value){
32
		return $value==0 || !$value;
33
	}
34
35
	public static function camelCaseToSeparated($input,$separator=" "){
36
		return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input));
37
	}
38
}