1
0

Util.php 484 B

12345678910111213141516171819202122
  1. <?php
  2. namespace App;
  3. use NumberFormatter;
  4. class Util {
  5. public static function slug(string $string, string $glue = "-"): string {
  6. $string = strtolower($string);
  7. return preg_replace("/[^a-z\d]+/i", $glue, $string);
  8. }
  9. public static function createDirectory(string $path): bool {
  10. return !mkdir($path, 0777, true) && !is_dir($path);
  11. }
  12. public static function getCurrencyFormatter(): NumberFormatter {
  13. return new NumberFormatter("en_GB", NumberFormatter::CURRENCY);
  14. }
  15. }