Canonicalizer.php 664 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /*
  3. * This file is part of the FOSUserBundle package.
  4. *
  5. * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace FOS\UserBundle\Util;
  11. class Canonicalizer implements CanonicalizerInterface
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function canonicalize($string)
  17. {
  18. $encoding = mb_detect_encoding($string);
  19. $result = $encoding
  20. ? mb_convert_case($string, MB_CASE_LOWER, $encoding)
  21. : mb_convert_case($string, MB_CASE_LOWER);
  22. return $result;
  23. }
  24. }