Skip to content

Commit 8529938

Browse files
committed
Update JString.php
1 parent dcc4d79 commit 8529938

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

Ajax/service/JString.php

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,78 @@
11
<?php
22
namespace Ajax\service;
3+
34
class JString {
45

5-
public static function contains($hay,$needle){
6+
public static function contains($hay, $needle) {
67
return strpos($hay, "$needle") !== false;
78
}
9+
810
public static function startswith($hay, $needle) {
911
return substr($hay, 0, strlen($needle)) === $needle;
1012
}
1113

1214
public static function endswith($hay, $needle) {
13-
return substr($hay, -strlen($needle)) === $needle;
15+
return substr($hay, - strlen($needle)) === $needle;
1416
}
1517

16-
public static function isNull($s){
17-
return (!isset($s) || NULL===$s || ""===$s);
18+
public static function isNull($s) {
19+
return (! isset($s) || NULL === $s || "" === $s);
1820
}
19-
public static function isNotNull($s){
20-
return (isset($s) && NULL!==$s && ""!==$s);
21+
22+
public static function isNotNull($s) {
23+
return (isset($s) && NULL !== $s && "" !== $s);
2124
}
2225

23-
public static function isBoolean($value){
24-
return \is_bool($value) || $value==1 || $value==0;
26+
public static function isBoolean($value) {
27+
return \is_bool($value) || $value == 1 || $value == 0;
2528
}
2629

27-
public static function isBooleanTrue($value){
28-
return $value==1 || $value;
30+
public static function isBooleanTrue($value) {
31+
return $value == 1 || $value;
2932
}
3033

31-
public static function isBooleanFalse($value){
32-
return $value==0 || !$value;
34+
public static function isBooleanFalse($value) {
35+
return $value == 0 || ! $value;
3336
}
3437

35-
public static function camelCaseToSeparated($input,$separator=" "){
36-
return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator.'$0', $input));
38+
public static function camelCaseToSeparated($input, $separator = " ") {
39+
return strtolower(preg_replace('/(?<!^)[A-Z]/', $separator . '$0', $input));
3740
}
3841

39-
public static function replaceAtFirst($subject,$from, $to){
40-
$from = '/\A'.preg_quote($from, '/').'/';
42+
public static function replaceAtFirst($subject, $from, $to) {
43+
$from = '/\A' . preg_quote($from, '/') . '/';
4144
return \preg_replace($from, $to, $subject, 1);
4245
}
4346

44-
public static function replaceAtLast($subject,$from, $to){
45-
$from = '/'.preg_quote($from, '/').'\z/';
47+
public static function replaceAtLast($subject, $from, $to) {
48+
$from = '/' . preg_quote($from, '/') . '\z/';
4649
return \preg_replace($from, $to, $subject, 1);
4750
}
4851

49-
public static function replaceAtFirstAndLast($subject,$fromFirst,$toFirst,$fromLast,$toLast){
50-
$s=self::replaceAtFirst($subject, $fromFirst, $toFirst);
52+
public static function replaceAtFirstAndLast($subject, $fromFirst, $toFirst, $fromLast, $toLast) {
53+
$s = self::replaceAtFirst($subject, $fromFirst, $toFirst);
5154
return self::replaceAtLast($s, $fromLast, $toLast);
5255
}
5356

54-
public static function getValueBetween(&$str,$before="{{",$after="}}"){
55-
$matches=[];
56-
$result=null;
57-
$_before=\preg_quote($before);
58-
$_after=\preg_quote($after);
59-
if(\preg_match('/'.$_before.'(.*?)'.$_after.'/s', $str, $matches)===1){
60-
$result=$matches[1];
61-
$str=\str_replace($before.$result.$after,"", $str);
57+
public static function getValueBetween(&$str, $before = "{{", $after = "}}") {
58+
$matches = [];
59+
$result = null;
60+
$_before = \preg_quote($before);
61+
$_after = \preg_quote($after);
62+
if (\preg_match('/' . $_before . '(.*?)' . $_after . '/s', $str, $matches) === 1) {
63+
$result = $matches[1];
64+
$str = \str_replace($before . $result . $after, "", $str);
6265
}
6366
return $result;
6467
}
65-
66-
public static function doubleBackSlashes($value){
67-
if(is_string($value))
68-
return str_replace("\\", "\\\\", $value);
69-
return $value;
68+
69+
public static function doubleBackSlashes($value) {
70+
if (\is_string($value))
71+
return \str_replace("\\", "\\\\", $value);
72+
return $value;
7073
}
7174

7275
public static function cleanIdentifier($id) {
73-
return preg_replace('/[^a-zA-Z0-9\-]/s', '', $id);
76+
return \preg_replace('/[^a-zA-Z0-9\-\_]/s', '', $id);
7477
}
7578
}

0 commit comments

Comments
 (0)