Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

StringUtils: phpdoc + cs

  • Loading branch information...
commit b17b3dea93048682b9f680aaae59f9d71593b0ed 1 parent 3dd2d06
Marc Bennewitz authored
18 library/Zend/Stdlib/StringWrapper/AbstractStringWrapper.php
@@ -25,21 +25,32 @@
25 25 */
26 26 protected $charsets = array();
27 27
  28 + /**
  29 + * Check if the given charset is supported
  30 + *
  31 + * @param string $charset
  32 + * @return boolean
  33 + */
28 34 public function isCharsetSupported($charset)
29 35 {
30 36 $charset = strtoupper($charset);
31 37 return in_array($charset, $this->charsets);
32 38 }
33 39
  40 + /**
  41 + * Get a list of supported charsets
  42 + *
  43 + * @return string[]
  44 + */
34 45 public function getSupportedCharsets()
35 46 {
36 47 return $this->$charsets;
37 48 }
38 49
39 50 /**
40   - * Word wrap
  51 + * Wraps a string to a given number of characters
41 52 *
42   - * @param string $string
  53 + * @param string $str
43 54 * @param integer $width
44 55 * @param string $break
45 56 * @param boolean $cut
@@ -117,7 +128,7 @@ public function wordWrap($string, $width = 75, $break = "\n", $cut = false, $cha
117 128 }
118 129
119 130 /**
120   - * String padding
  131 + * Pad a string to a certain length with another string
121 132 *
122 133 * @param string $input
123 134 * @param integer $padLength
@@ -167,3 +178,4 @@ public function strPad($input, $padLength, $padString = ' ', $padType = \STR_PAD
167 178 return $return;
168 179 }
169 180 }
  181 +
34 library/Zend/Stdlib/StringWrapper/Iconv.php
@@ -46,23 +46,57 @@ public function __construct()
46 46 }
47 47 }
48 48
  49 + /**
  50 + * Returns the length of the given string
  51 + *
  52 + * @param string $str
  53 + * @param string $charset
  54 + * @return int|false
  55 + */
49 56 public function strlen($str, $charset = 'UTF-8')
50 57 {
51 58 return iconv_strlen($str, $charset);
52 59 }
53 60
  61 + /**
  62 + * Returns the portion of string specified by the start and length parameters
  63 + *
  64 + * @param string $str
  65 + * @param int $offset
  66 + * @param int|null $length
  67 + * @param string $charset
  68 + * @return string|false
  69 + */
54 70 public function substr($str, $offset = 0, $length = null, $charset = 'UTF-8')
55 71 {
56 72 return iconv_substr($str, $offset, $length, $charset);
57 73 }
58 74
  75 + /**
  76 + * Find the position of the first occurrence of a substring in a string
  77 + *
  78 + * @param string $haystack
  79 + * @param string $needle
  80 + * @param int $offset
  81 + * @param string $charset
  82 + * @return int|false
  83 + */
59 84 public function strpos($haystack, $needle, $offset = 0, $charset = 'UTF-8')
60 85 {
61 86 return iconv_strpos($haystack, $needle, $offset, $charset);
62 87 }
63 88
  89 + /**
  90 + * Convert a string from one character encoding to another
  91 + *
  92 + * @param string $str
  93 + * @param string $toCharset
  94 + * @param string $fromCharset
  95 + * @return string|false
  96 + */
64 97 public function convert($str, $toCharset, $fromCharset = 'UTF-8')
65 98 {
66 99 return iconv($fromCharset, $toCharset, $str);
67 100 }
68 101 }
  102 +
34 library/Zend/Stdlib/StringWrapper/Intl.php
@@ -39,6 +39,13 @@ public function __construct()
39 39 }
40 40 }
41 41
  42 + /**
  43 + * Returns the length of the given string
  44 + *
  45 + * @param string $str
  46 + * @param string $charset
  47 + * @return int|false
  48 + */
42 49 public function strlen($str, $charset = 'UTF-8')
43 50 {
44 51 if (strcasecmp($charset, 'UTF-8') != 0) {
@@ -49,6 +56,15 @@ public function strlen($str, $charset = 'UTF-8')
49 56 return grapheme_strlen($str);
50 57 }
51 58
  59 + /**
  60 + * Returns the portion of string specified by the start and length parameters
  61 + *
  62 + * @param string $str
  63 + * @param int $offset
  64 + * @param int|null $length
  65 + * @param string $charset
  66 + * @return string|false
  67 + */
52 68 public function substr($str, $offset = 0, $length = null, $charset = 'UTF-8')
53 69 {
54 70 if (strcasecmp($charset, 'UTF-8') != 0) {
@@ -59,6 +75,15 @@ public function substr($str, $offset = 0, $length = null, $charset = 'UTF-8')
59 75 return grapheme_substr($str, $offset, $length);
60 76 }
61 77
  78 + /**
  79 + * Find the position of the first occurrence of a substring in a string
  80 + *
  81 + * @param string $haystack
  82 + * @param string $needle
  83 + * @param int $offset
  84 + * @param string $charset
  85 + * @return int|false
  86 + */
62 87 public function strpos($haystack, $needle, $offset = 0, $charset = 'UTF-8')
63 88 {
64 89 if (strcasecmp($charset, 'UTF-8') != 0) {
@@ -69,6 +94,14 @@ public function strpos($haystack, $needle, $offset = 0, $charset = 'UTF-8')
69 94 return grapheme_strpos($haystack, $needle, $offset);
70 95 }
71 96
  97 + /**
  98 + * Convert a string from one character encoding to another
  99 + *
  100 + * @param string $str
  101 + * @param string $toCharset
  102 + * @param string $fromCharset
  103 + * @return string|false
  104 + */
72 105 public function convert($str, $toCharset, $fromCharset = 'UTF-8')
73 106 {
74 107 if (strcasecmp($toCharset, $fromCharset) != 0) {
@@ -79,3 +112,4 @@ public function convert($str, $toCharset, $fromCharset = 'UTF-8')
79 112 return true;
80 113 }
81 114 }
  115 +
34 library/Zend/Stdlib/StringWrapper/MbString.php
@@ -48,23 +48,57 @@ public function __construct()
48 48 }
49 49 }
50 50
  51 + /**
  52 + * Returns the length of the given string
  53 + *
  54 + * @param string $str
  55 + * @param string $charset
  56 + * @return int|false
  57 + */
51 58 public function strlen($str, $charset = 'UTF-8')
52 59 {
53 60 return mb_strlen($str, $charset);
54 61 }
55 62
  63 + /**
  64 + * Returns the portion of string specified by the start and length parameters
  65 + *
  66 + * @param string $str
  67 + * @param int $offset
  68 + * @param int|null $length
  69 + * @param string $charset
  70 + * @return string|false
  71 + */
56 72 public function substr($str, $offset = 0, $length = null, $charset = 'UTF-8')
57 73 {
58 74 return mb_substr($str, $offset, $length, $charset);
59 75 }
60 76
  77 + /**
  78 + * Find the position of the first occurrence of a substring in a string
  79 + *
  80 + * @param string $haystack
  81 + * @param string $needle
  82 + * @param int $offset
  83 + * @param string $charset
  84 + * @return int|false
  85 + */
61 86 public function strpos($haystack, $needle, $offset = 0, $charset = 'UTF-8')
62 87 {
63 88 return mb_strpos($haystack, $needle, $offset, $charset);
64 89 }
65 90
  91 + /**
  92 + * Convert a string from one character encoding to another
  93 + *
  94 + * @param string $str
  95 + * @param string $toCharset
  96 + * @param string $fromCharset
  97 + * @return string|false
  98 + */
66 99 public function convert($str, $toCharset, $fromCharset = 'UTF-8')
67 100 {
68 101 return mb_convert_encoding($str, $toCharset, $fromCharset);
69 102 }
70 103 }
  104 +
38 library/Zend/Stdlib/StringWrapper/Native.php
@@ -19,28 +19,66 @@
19 19 */
20 20 class Native extends AbstractStringWrapper
21 21 {
  22 +
  23 + /**
  24 + * Constructor
  25 + */
22 26 public function __construct()
23 27 {
24 28 $this->charsets = StringUtils::getSingleByteCharsets();
25 29 }
26 30
  31 + /**
  32 + * Returns the length of the given string
  33 + *
  34 + * @param string $str
  35 + * @param string $charset
  36 + * @return int|false
  37 + */
27 38 public function strlen($str, $charset = 'UTF-8')
28 39 {
29 40 return strlen($str);
30 41 }
31 42
  43 + /**
  44 + * Returns the portion of string specified by the start and length parameters
  45 + *
  46 + * @param string $str
  47 + * @param int $offset
  48 + * @param int|null $length
  49 + * @param string $charset
  50 + * @return string|false
  51 + */
32 52 public function substr($str, $offset = 0, $length = null, $charset = 'UTF-8')
33 53 {
34 54 return substr($str, $offset, $length);
35 55 }
36 56
  57 + /**
  58 + * Find the position of the first occurrence of a substring in a string
  59 + *
  60 + * @param string $haystack
  61 + * @param string $needle
  62 + * @param int $offset
  63 + * @param string $charset
  64 + * @return int|false
  65 + */
37 66 public function strpos($haystack, $needle, $offset = 0, $charset = 'UTF-8')
38 67 {
39 68 return strpos($haystack, $needle, $offset);
40 69 }
41 70
  71 + /**
  72 + * Convert a string from one character encoding to another
  73 + *
  74 + * @param string $str
  75 + * @param string $toCharset
  76 + * @param string $fromCharset
  77 + * @return string|false
  78 + */
42 79 public function convert($str, $toCharset, $fromCharset = 'UTF-8')
43 80 {
44 81 return false;
45 82 }
46 83 }
  84 +
3  library/Zend/Stdlib/StringWrapper/StringWrapperInterface.php
@@ -38,7 +38,7 @@ public function getSupportedCharsets();
38 38 *
39 39 * @param string $str
40 40 * @param string $charset
41   - * @return int
  41 + * @return int|false
42 42 */
43 43 public function strlen($str, $charset = 'UTF-8');
44 44
@@ -98,3 +98,4 @@ public function wordWrap($str, $width = 75, $break = "\n", $cut = false, $charse
98 98 */
99 99 public function strPad($input, $padLength, $padString = ' ', $padType = \STR_PAD_RIGHT, $charset = 'UTF-8');
100 100 }
  101 +

0 comments on commit b17b3de

Please sign in to comment.
Something went wrong with that request. Please try again.