-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractStr.php
98 lines (89 loc) · 1.78 KB
/
AbstractStr.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
declare(strict_types=1);
/*
* This file is part of the Niga PHP framework package
*
* (c) Abass Dev <[email protected]>
*/
namespace Niga\Framework\Support;
use Niga\Framework\Support\Exception\StrException;
/**
* String supports
*
* @author Abass Dev <[email protected]>
*/
abstract class AbstractStr
{
/**
* Check if the given data is string type
*
* @param string $isStr
* @return int
* @throws StrException
*/
protected static function isString($isStr)
{
if(is_string($isStr)){
return true;
} else {
return false;
}
}
/**
* Check if the given data is numeric type
*
* @param mixed $isNum
* @return mixed
* @throws StrException
*/
protected static function isNumeric($isNum)
{
if(is_numeric($isNum)){
return true;
}
return false;
}
/**
* Check if the given data is int type
*
* @param int $isInt
* @return numeric
* @throws StrException
*/
protected static function isInteger($isInt)
{
if (filter_var($isInt, FILTER_VALIDATE_INT) === false || !is_int($isInt)) {
return false;
}
return true;
}
/**
* Get string length
*
* @param string $str
* @return int
* @throws StrException
*/
protected static function strLength($str)
{
if (static::isString($str)) {
return strlen($str);
}
return false;
}
/**
* Get string position
*
* @param string $str
* @return int|bool
* @throws StrException
*/
protected static function strPos($pos, $str)
{
if (static::isString($str)) {
return strpos($pos, $str);
} else {
return false;
}
}
}