1: <?php
2:
3: namespace Deimos\Helper\Helpers\Str;
4:
5: trait DefaultTrait
6: {
7:
8: 9: 10: 11: 12: 13: 14:
15: public function sub($string, $start, $length = null)
16: {
17: return mb_substr($string, $start, $length);
18: }
19:
20: 21: 22: 23: 24:
25: public function upp($string)
26: {
27: return mb_convert_case($string, MB_CASE_UPPER);
28: }
29:
30: 31: 32: 33: 34:
35: public function low($string)
36: {
37: return mb_convert_case($string, MB_CASE_LOWER);
38: }
39:
40: 41: 42: 43: 44:
45: public function capitalize($string)
46: {
47: return mb_convert_case($string, MB_CASE_TITLE);
48: }
49:
50: 51: 52: 53: 54:
55: public function toNumber($string)
56: {
57: return preg_replace('/\D/', '', $string);
58: }
59:
60: 61: 62: 63: 64:
65: public function len($string)
66: {
67: return mb_strlen($string);
68: }
69:
70: 71: 72: 73: 74: 75: 76:
77: public function pos($string, $needle, $offset = null)
78: {
79: return mb_strpos($string, $needle, $offset);
80: }
81:
82: 83: 84: 85: 86: 87:
88: public function repeat($string, $multiplier)
89: {
90: return str_repeat($string, $multiplier);
91: }
92:
93: 94: 95: 96: 97:
98: public function shuffle($string)
99: {
100: return $this->rand($string, $this->len($string));
101: }
102:
103: }
104: