Skip to content

Commit c76c37d

Browse files
author
Martin Brecht-Precht
committed
Switched the root namespace and vendor prefix.
1 parent ce02ea5 commit c76c37d

File tree

6 files changed

+57
-53
lines changed

6 files changed

+57
-53
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Martin Brecht-Precht, Markenwerk GmbH
3+
Copyright (c) 2016 Martin Brecht-Precht, Chroma Experience GmbH
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# PHP String Builder
22

3-
[![Build Status](https://travis-ci.org/markenwerk/php-string-builder.svg?branch=master)](https://travis-ci.org/markenwerk/php-string-builder)
4-
[![Test Coverage](https://codeclimate.com/github/markenwerk/php-string-builder/badges/coverage.svg)](https://codeclimate.com/github/markenwerk/php-string-builder/coverage)
3+
[![Build Status](https://travis-ci.org/chroma-x/php-string-builder.svg?branch=master)](https://travis-ci.org/chroma-x/php-string-builder)
4+
[![Test Coverage](https://codeclimate.com/github/chroma-x/php-string-builder/badges/coverage.svg)](https://codeclimate.com/github/chroma-x/php-string-builder/coverage)
55
[![Dependency Status](https://www.versioneye.com/user/projects/57aa33adf27cc20050102f0e/badge.svg)](https://www.versioneye.com/user/projects/57aa33adf27cc20050102f0e)
66
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/ec36917d-baa1-482c-8916-41e2a2c48d5c.svg)](https://insight.sensiolabs.com/projects/ec36917d-baa1-482c-8916-41e2a2c48d5c)
7-
[![Code Climate](https://codeclimate.com/github/markenwerk/php-string-builder/badges/gpa.svg)](https://codeclimate.com/github/markenwerk/php-string-builder)
8-
[![Latest Stable Version](https://poser.pugx.org/markenwerk/string-builder/v/stable)](https://packagist.org/packages/markenwerk/string-builder)
9-
[![Total Downloads](https://poser.pugx.org/markenwerk/string-builder/downloads)](https://packagist.org/packages/markenwerk/string-builder)
10-
[![License](https://poser.pugx.org/markenwerk/string-builder/license)](https://packagist.org/packages/markenwerk/string-builder)
7+
[![Code Climate](https://codeclimate.com/github/chroma-x/php-string-builder/badges/gpa.svg)](https://codeclimate.com/github/chroma-x/php-string-builder)
8+
[![Latest Stable Version](https://poser.pugx.org/chroma-x/string-builder/v/stable)](https://packagist.org/packages/chroma-x/string-builder)
9+
[![Total Downloads](https://poser.pugx.org/chroma-x/string-builder/downloads)](https://packagist.org/packages/chroma-x/string-builder)
10+
[![License](https://poser.pugx.org/chroma-x/string-builder/license)](https://packagist.org/packages/chroma-x/string-builder)
1111

1212
A basic string builder library providing different string methods written in PHP.
1313

@@ -16,7 +16,7 @@ A basic string builder library providing different string methods written in PHP
1616
```{json}
1717
{
1818
"require": {
19-
"markenwerk/string-builder": "~1.0"
19+
"chroma-x/string-builder": "~1.0"
2020
}
2121
}
2222
```
@@ -32,7 +32,7 @@ require_once('path/to/vendor/autoload.php');
3232
### Building and modifying a string
3333

3434
```{php}
35-
use Markenwerk\StringBuilder\StringBuilder;
35+
use ChromaX\StringBuilder\StringBuilder;
3636
3737
$builder = new StringBuilder('rolod muspi meroL');
3838
$builder
@@ -121,7 +121,7 @@ will output the following
121121
All methods throw an `\InvalidArgumentException` if misconfigured except `indexOf` and `lastIndexOf` wich return `null` if the given subtring is not contained by the string to build.
122122

123123
```{php}
124-
use Markenwerk\StringBuilder\StringBuilder;
124+
use ChromaX\StringBuilder\StringBuilder;
125125
126126
try {
127127
$builder = new StringBuilder();
@@ -153,7 +153,7 @@ Exception with message Position invalid
153153
## Contribution
154154

155155
Contributing to our projects is always very appreciated.
156-
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/markenwerk/php-string-builder/blob/master/CONTRIBUTING.md) document.**
156+
**But: please follow the contribution guidelines written down in the [CONTRIBUTING.md](https://github.com/chroma-x/php-string-builder/blob/master/CONTRIBUTING.md) document.**
157157

158158
## License
159159

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"name": "markenwerk/string-builder",
2+
"name": "chroma-x/string-builder",
33
"type": "library",
44
"description": "A string builder library providing different string methods written in PHP.",
55
"keywords": [
66
"String",
77
"Builder"
88
],
9-
"homepage": "http://markenwerk.net/",
9+
"homepage": "http://chroma-x.de/",
1010
"license": "MIT",
1111
"authors": [
1212
{
1313
"name": "Martin Brecht-Precht",
14-
"email": "mb@markenwerk.net",
15-
"homepage": "http://markenwerk.net"
14+
"email": "mb@chroma-x.de",
15+
"homepage": "http://chroma-x.de"
1616
}
1717
],
1818
"autoload": {
1919
"psr-4": {
20-
"Markenwerk\\StringBuilder\\": "src/"
20+
"ChromaX\\StringBuilder\\": "src/"
2121
}
2222
},
2323
"require": {

src/StringBuilder.php

+26-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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
*/
1213
class 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);

src/Util/ArgumentValidator.php

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
<?php
22

3-
namespace Markenwerk\StringBuilder\Util;
3+
namespace ChromaX\StringBuilder\Util;
4+
5+
use InvalidArgumentException;
46

57
/**
68
* Class ArgumentValidator
79
*
8-
* @package Markenwerk\StringBuilder\Util
10+
* @package ChromaX\StringBuilder\Util
911
*/
10-
class ArgumentValidator{
12+
class ArgumentValidator
13+
{
1114

1215
/**
1316
* @param mixed $value
14-
* @throws \InvalidArgumentException
17+
* @throws InvalidArgumentException
1518
*/
1619
public static function validateScalar($value)
1720
{
1821
if (!is_scalar($value)) {
1922
$type = is_object($value) ? get_class($value) : gettype($value);
20-
throw new \InvalidArgumentException('Expected a scalar value; got ' . $type);
23+
throw new InvalidArgumentException('Expected a scalar value; got ' . $type);
2124
}
2225
}
2326

2427
/**
2528
* @param mixed $value
26-
* @throws \InvalidArgumentException
29+
* @throws InvalidArgumentException
2730
*/
2831
public static function validateUnsignedInteger($value)
2932
{
3033
if (!is_int($value)) {
3134
$type = is_object($value) ? get_class($value) : gettype($value);
32-
throw new \InvalidArgumentException('Expected an unsigned integer; got ' . $type);
35+
throw new InvalidArgumentException('Expected an unsigned integer; got ' . $type);
3336
}
3437
if ($value < 0) {
35-
throw new \InvalidArgumentException('Expected an unsigned integer; got ' . $value);
38+
throw new InvalidArgumentException('Expected an unsigned integer; got ' . $value);
3639
}
3740
}
3841

3942
/**
4043
* @param mixed $value
41-
* @throws \InvalidArgumentException
44+
* @throws InvalidArgumentException
4245
*/
4346
public static function validateUnsignedIntegerOrNull($value)
4447
{
@@ -50,13 +53,13 @@ public static function validateUnsignedIntegerOrNull($value)
5053

5154
/**
5255
* @param mixed $value
53-
* @throws \InvalidArgumentException
56+
* @throws InvalidArgumentException
5457
*/
5558
public static function validateEmpty($value)
5659
{
5760
$value = (string)$value;
5861
if (empty($value)) {
59-
throw new \InvalidArgumentException('Empty string is invalid');
62+
throw new InvalidArgumentException('Empty string is invalid');
6063
}
6164
}
6265

test/StringBuilderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Test;
44

5-
use Markenwerk\StringBuilder\StringBuilder;
5+
use ChromaX\StringBuilder\StringBuilder;
66

77
/**
88
* Class StringBuilderTest

0 commit comments

Comments
 (0)