/xandra.org/www/application/classes/Dust/Filter/EncodeUriComponent.php

https://bitbucket.org/ekkl/tanora · PHP · 19 lines · 16 code · 3 blank · 0 comment · 1 complexity · fb4e9b42c7c638a8f3f32f10c766492a MD5 · raw file

  1. <?php
  2. namespace Dust\Filter;
  3. class EncodeUriComponent implements Filter {
  4. public static $replacers;
  5. public function apply($item) {
  6. if (!is_string($item)) return $item;
  7. return strtr(rawurlencode($item), EncodeUriComponent::$replacers);
  8. }
  9. }
  10. EncodeUriComponent::$replacers = [
  11. '%21' => '!',
  12. '%2A' => '*',
  13. '%27' => "'",
  14. '%28' => '(',
  15. '%29' => ')'
  16. ];