-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtruncation.php
69 lines (60 loc) · 1.32 KB
/
truncation.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
<?php
/**
*
*/
class WordTruncat
{
public $_name = '';
public $_version;
public $_getupper;
function __construct($exceptions=true)
{
$this->Name = $this->_name;
$this->GetUpper = $this->_getupper;
}
public static function truncatFunction(string $string_name = NULL,int $length = 0,string $limiter = "...")
{
$data = $string_name;
$getLength = strlen($string_name);
$dataSize = $length;
$delimiter = $limiter;
if (!empty($data) && is_string($data)) {
if ($getLength > 0 && $getLength >= $dataSize) {
$finalString = "";
//Trying something out to see the effect
for ($i=0; $i <= $dataSize; $i++)
{
if ($i == $dataSize) {
# code...
$finalString .= " ".$delimiter;
}
else{
$finalString .= $data[$i];
}
}
return $finalString;
}
else{
return $data;
}
}
else{
return "something happened";
}
}
function toUpperCase(string $name){
return ucfirst($name);
}
function getCharacter(string $username){
$this->_name = $username;
if(!empty($this->_name) && is_string($this->_name))
{
$this->_getupper = $this->toUpperCase($this->_name[0]);
return $this->_getupper;
}
else{
return "Argument Not A String";
}
}
}
?>