11<?php
22
3- namespace Markenwerk \StringBuilder ;
3+ namespace ChromaX \StringBuilder ;
44
5- use Markenwerk \StringBuilder \Util \ArgumentValidator ;
5+ use ChromaX \StringBuilder \Util \ArgumentValidator ;
6+ use InvalidArgumentException ;
67
78/**
89 * Class StringBuilder
910 *
10- * @package Markenwerk \StringBuilder
11+ * @package ChromaX \StringBuilder
1112 */
1213class StringBuilder
1314{
@@ -23,7 +24,7 @@ class StringBuilder
2324 * Takes an initial string as argument
2425 *
2526 * @param null $string
26- * @throws \ InvalidArgumentException
27+ * @throws InvalidArgumentException
2728 */
2829 public function __construct ($ string = null )
2930 {
@@ -38,7 +39,7 @@ public function __construct($string = null)
3839 *
3940 * @param string $string
4041 * @return $this
41- * @throws \ InvalidArgumentException
42+ * @throws InvalidArgumentException
4243 */
4344 public function append ($ string )
4445 {
@@ -52,7 +53,7 @@ public function append($string)
5253 *
5354 * @param string $string
5455 * @return $this
55- * @throws \ InvalidArgumentException
56+ * @throws InvalidArgumentException
5657 */
5758 public function prepend ($ string )
5859 {
@@ -67,14 +68,14 @@ public function prepend($string)
6768 * @param int $position
6869 * @param string $string
6970 * @return $this
70- * @throws \ InvalidArgumentException
71+ * @throws InvalidArgumentException
7172 */
7273 public function insert ($ position , $ string )
7374 {
7475 ArgumentValidator::validateUnsignedInteger ($ position );
7576 ArgumentValidator::validateScalar ($ string );
7677 if ($ position >= $ this ->length ()) {
77- throw new \ InvalidArgumentException ('Position invalid ' );
78+ throw new InvalidArgumentException ('Position invalid ' );
7879 }
7980 $ this ->string = mb_substr ($ this ->string , 0 , $ position ) . (string )$ string . mb_substr ($ this ->string , $ position );
8081 return $ this ;
@@ -87,18 +88,18 @@ public function insert($position, $string)
8788 * @param int $length
8889 * @param string $string
8990 * @return $this
90- * @throws \ InvalidArgumentException
91+ * @throws InvalidArgumentException
9192 */
9293 public function replace ($ position , $ length , $ string )
9394 {
9495 ArgumentValidator::validateUnsignedInteger ($ position );
9596 ArgumentValidator::validateUnsignedInteger ($ length );
9697 ArgumentValidator::validateScalar ($ string );
9798 if ($ position >= $ this ->length ()) {
98- throw new \ InvalidArgumentException ('Position invalid ' );
99+ throw new InvalidArgumentException ('Position invalid ' );
99100 }
100101 if ($ position + $ length > $ this ->length ()) {
101- throw new \ InvalidArgumentException ('Length invalid ' );
102+ throw new InvalidArgumentException ('Length invalid ' );
102103 }
103104 $ this ->string = mb_substr ($ this ->string , 0 , $ position ) . (string )$ string . mb_substr ($ this ->string , $ position + $ length );
104105 return $ this ;
@@ -110,17 +111,17 @@ public function replace($position, $length, $string)
110111 * @param int $position
111112 * @param string $character
112113 * @return $this
113- * @throws \ InvalidArgumentException
114+ * @throws InvalidArgumentException
114115 */
115116 public function setCharAt ($ position , $ character )
116117 {
117118 ArgumentValidator::validateUnsignedInteger ($ position );
118119 ArgumentValidator::validateScalar ($ character );
119120 if ($ position >= $ this ->length ()) {
120- throw new \ InvalidArgumentException ('Position invalid ' );
121+ throw new InvalidArgumentException ('Position invalid ' );
121122 }
122123 if (mb_strlen ((string )$ character ) !== 1 ) {
123- throw new \ InvalidArgumentException ('Expected a scalar value of length 1 ' );
124+ throw new InvalidArgumentException ('Expected a scalar value of length 1 ' );
124125 }
125126 $ this ->string = mb_substr ($ this ->string , 0 , $ position ) . (string )$ character . mb_substr ($ this ->string , $ position + 1 );
126127 return $ this ;
@@ -148,14 +149,14 @@ public function reverse()
148149 * @param int $position
149150 * @param int $length
150151 * @return $this
151- * @throws \ InvalidArgumentException
152+ * @throws InvalidArgumentException
152153 */
153154 public function delete ($ position , $ length = null )
154155 {
155156 ArgumentValidator::validateUnsignedInteger ($ position );
156157 ArgumentValidator::validateUnsignedIntegerOrNull ($ length );
157158 if ($ position >= $ this ->length ()) {
158- throw new \ InvalidArgumentException ('Position invalid ' );
159+ throw new InvalidArgumentException ('Position invalid ' );
159160 }
160161 if ($ length === null ) {
161162 $ this ->string = mb_substr ($ this ->string , 0 , $ position );
@@ -170,13 +171,13 @@ public function delete($position, $length = null)
170171 *
171172 * @param int $position
172173 * @return $this
173- * @throws \ InvalidArgumentException
174+ * @throws InvalidArgumentException
174175 */
175176 public function deleteCharAt ($ position )
176177 {
177178 ArgumentValidator::validateUnsignedInteger ($ position );
178179 if ($ position >= $ this ->length ()) {
179- throw new \ InvalidArgumentException ('Position invalid ' );
180+ throw new InvalidArgumentException ('Position invalid ' );
180181 }
181182 $ this ->string = mb_substr ($ this ->string , 0 , $ position ) . mb_substr ($ this ->string , $ position + 1 );
182183 return $ this ;
@@ -187,7 +188,7 @@ public function deleteCharAt($position)
187188 *
188189 * @param string $substring
189190 * @return bool
190- * @throws \ InvalidArgumentException
191+ * @throws InvalidArgumentException
191192 */
192193 public function contains ($ substring )
193194 {
@@ -203,7 +204,7 @@ public function contains($substring)
203204 * @param string $string
204205 * @param int $offset
205206 * @return int
206- * @throws \ InvalidArgumentException
207+ * @throws InvalidArgumentException
207208 */
208209 public function indexOf ($ string , $ offset = 0 )
209210 {
@@ -222,7 +223,7 @@ public function indexOf($string, $offset = 0)
222223 * @param string $string
223224 * @param int $offset
224225 * @return int
225- * @throws \ InvalidArgumentException
226+ * @throws InvalidArgumentException
226227 */
227228 public function lastIndexOf ($ string , $ offset = 0 )
228229 {
@@ -258,13 +259,13 @@ public function length()
258259 *
259260 * @param int $position
260261 * @return string
261- * @throws \ InvalidArgumentException
262+ * @throws InvalidArgumentException
262263 */
263264 public function charAt ($ position )
264265 {
265266 ArgumentValidator::validateUnsignedInteger ($ position );
266267 if ($ position >= $ this ->length ()) {
267- throw new \ InvalidArgumentException ('Position invalid ' );
268+ throw new InvalidArgumentException ('Position invalid ' );
268269 }
269270 return mb_substr ($ this ->string , $ position , 1 );
270271 }
@@ -295,14 +296,14 @@ public function lastChar()
295296 * @param int $startPosition
296297 * @param int $length
297298 * @return string
298- * @throws \ InvalidArgumentException
299+ * @throws InvalidArgumentException
299300 */
300301 public function buildSubstring ($ startPosition , $ length = null )
301302 {
302303 ArgumentValidator::validateUnsignedInteger ($ startPosition );
303304 ArgumentValidator::validateUnsignedIntegerOrNull ($ length );
304305 if ($ startPosition >= $ this ->length ()) {
305- throw new \ InvalidArgumentException ('Start position ' . (string )$ startPosition . ' invalid ' );
306+ throw new InvalidArgumentException ('Start position ' . (string )$ startPosition . ' invalid ' );
306307 }
307308 if ($ length === null ) {
308309 return mb_substr ($ this ->string , $ startPosition );
0 commit comments