StringWrapperInterface.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. */
  9. namespace Zend\Stdlib\StringWrapper;
  10. interface StringWrapperInterface
  11. {
  12. /**
  13. * Check if the given character encoding is supported by this wrapper
  14. * and the character encoding to convert to is also supported.
  15. *
  16. * @param string $encoding
  17. * @param string|null $convertEncoding
  18. */
  19. public static function isSupported($encoding, $convertEncoding = null);
  20. /**
  21. * Get a list of supported character encodings
  22. *
  23. * @return string[]
  24. */
  25. public static function getSupportedEncodings();
  26. /**
  27. * Set character encoding working with and convert to
  28. *
  29. * @param string $encoding The character encoding to work with
  30. * @param string|null $convertEncoding The character encoding to convert to
  31. * @return StringWrapperInterface
  32. */
  33. public function setEncoding($encoding, $convertEncoding = null);
  34. /**
  35. * Get the defined character encoding to work with (upper case)
  36. *
  37. * @return string
  38. */
  39. public function getEncoding();
  40. /**
  41. * Get the defined character encoding to convert to (upper case)
  42. *
  43. * @return string|null
  44. */
  45. public function getConvertEncoding();
  46. /**
  47. * Returns the length of the given string
  48. *
  49. * @param string $str
  50. * @return int|false
  51. */
  52. public function strlen($str);
  53. /**
  54. * Returns the portion of string specified by the start and length parameters
  55. *
  56. * @param string $str
  57. * @param int $offset
  58. * @param int|null $length
  59. * @return string|false
  60. */
  61. public function substr($str, $offset = 0, $length = null);
  62. /**
  63. * Find the position of the first occurrence of a substring in a string
  64. *
  65. * @param string $haystack
  66. * @param string $needle
  67. * @param int $offset
  68. * @return int|false
  69. */
  70. public function strpos($haystack, $needle, $offset = 0);
  71. /**
  72. * Convert a string from defined encoding to the defined convert encoding
  73. *
  74. * @param string $str
  75. * @param bool $reverse
  76. * @return string|false
  77. */
  78. public function convert($str, $reverse = false);
  79. /**
  80. * Wraps a string to a given number of characters
  81. *
  82. * @param string $str
  83. * @param int $width
  84. * @param string $break
  85. * @param bool $cut
  86. * @return string
  87. */
  88. public function wordWrap($str, $width = 75, $break = "\n", $cut = false);
  89. /**
  90. * Pad a string to a certain length with another string
  91. *
  92. * @param string $input
  93. * @param int $padLength
  94. * @param string $padString
  95. * @param int $padType
  96. * @return string
  97. */
  98. public function strPad($input, $padLength, $padString = ' ', $padType = STR_PAD_RIGHT);
  99. }