Image
2 days ago
Select
2 days ago
Arrays.php
2 days ago
AvailableTranslations.php
2 days ago
Creatable.php
2 days ago
Dashicon.php
2 days ago
Date.php
2 days ago
Html.php
2 days ago
Icon.php
2 days ago
Image.php
2 days ago
LocalFile.php
2 days ago
Mbstring.php
2 days ago
MediaIdResolver.php
2 days ago
Menu.php
2 days ago
Network.php
2 days ago
Post.php
2 days ago
Strings.php
2 days ago
Taxonomy.php
2 days ago
User.php
2 days ago
UserRoles.php
2 days ago
WpDateFormat.php
2 days ago
Mbstring.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Helper; |
| 6 | |
| 7 | final class Mbstring |
| 8 | { |
| 9 | public static function strlen(string $string): int |
| 10 | { |
| 11 | return function_exists('mb_strlen') |
| 12 | ? mb_strlen($string) |
| 13 | : strlen($string); |
| 14 | } |
| 15 | |
| 16 | public static function strtolower(string $string): string |
| 17 | { |
| 18 | return function_exists('mb_strtolower') |
| 19 | ? mb_strtolower($string) |
| 20 | : strtolower($string); |
| 21 | } |
| 22 | |
| 23 | public static function substr(string $string, int $start, ?int $length = null): string |
| 24 | { |
| 25 | if (function_exists('mb_substr')) { |
| 26 | return mb_substr($string, $start, $length); |
| 27 | } |
| 28 | |
| 29 | return (string)substr($string, $start, $length ?? PHP_INT_MAX); |
| 30 | } |
| 31 | |
| 32 | } |
| 33 |