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