1 | <?php |
||
5 | trait StringLength |
||
6 | { |
||
7 | /** |
||
8 | * Tags the should not be ultimately considered |
||
9 | * when calculating any string lengths |
||
10 | * |
||
11 | * @var array $ignore_tags |
||
12 | */ |
||
13 | protected $ignore_tags = []; |
||
14 | |||
15 | /** |
||
16 | * Set the ignore tags property |
||
17 | */ |
||
18 | 104 | protected function setIgnoreTags() |
|
24 | |||
25 | /** |
||
26 | * Determine the length of the string without any tags |
||
27 | * |
||
28 | * @param string $str |
||
29 | * |
||
30 | * @return integer |
||
31 | */ |
||
32 | 104 | protected function lengthWithoutTags($str) |
|
38 | |||
39 | /** |
||
40 | * Get the string without the tags that are to be ignored |
||
41 | * |
||
42 | * @param string $str |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 104 | protected function withoutTags($str) |
|
52 | |||
53 | /** |
||
54 | * Apply padding to a string |
||
55 | * |
||
56 | * @param string $str |
||
57 | * @param string $final_length |
||
58 | * @param string $padding_side |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | 88 | protected function pad($str, $final_length, $padding_side = 'right') |
|
72 | |||
73 | /** |
||
74 | * Apply padding to an array of strings |
||
75 | * |
||
76 | * @param array $arr |
||
77 | * @param integer $final_length |
||
78 | * @param string $padding_side |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | 28 | protected function padArray($arr, $final_length, $padding_side = 'right') |
|
90 | |||
91 | /** |
||
92 | * Find the max string length in an array |
||
93 | * |
||
94 | * @param array $arr |
||
95 | * @return int |
||
96 | */ |
||
97 | 52 | protected function maxStrLen(array $arr) |
|
101 | |||
102 | /** |
||
103 | * Get an array of the string lengths from an array of strings |
||
104 | * |
||
105 | * @param array $arr |
||
106 | * @return array |
||
107 | */ |
||
108 | 80 | protected function arrayOfStrLens(array $arr) |
|
112 | } |
||
113 |