Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

Commit

Permalink
Rename Hoa\String to Hoa\Ustring.
Browse files Browse the repository at this point in the history
Quoting https://github.com/php/php-src/blob/7dcfdbbee4/UPGRADING#L378-L387:

> It is no longer possible to use the following class, interface and trait names
> (case-insensitive):
>
>   * bool
>   * int
>   * float
>   * string
>   * null
>   * false
>   * true
  • Loading branch information
Hywan committed May 29, 2015
1 parent cedbbdb commit 0278566
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 236 deletions.
10 changes: 5 additions & 5 deletions Bin/Fromcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String\Bin;
namespace Hoa\Ustring\Bin;

use Hoa\Console;
use Hoa\String;
use Hoa\Ustring;

/**
* Class Hoa\String\Bin\Fromcode.
* Class Hoa\Ustring\Bin\Fromcode.
*
* Get a character from its code. Please, see Hoa\String\String::fromCode.
* Get a character from its code. Please, see Hoa\Ustring\Ustring::fromCode.
*
* @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
Expand Down Expand Up @@ -92,7 +92,7 @@ public function main()

$this->parser->listInputs($code);

$char = String::fromCode(base_convert($code, $base, 10));
$char = Ustring::fromCode(base_convert($code, $base, 10));

echo $char;

Expand Down
10 changes: 5 additions & 5 deletions Bin/Tocode.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String\Bin;
namespace Hoa\Ustring\Bin;

use Hoa\Console;
use Hoa\String;
use Hoa\Ustring;

/**
* Class Hoa\String\Bin\Tocode.
* Class Hoa\Ustring\Bin\Tocode.
*
* Transform a character into its code. Please, see Hoa\String\String::toCode.
* Transform a character into its code. Please, see Hoa\Ustring\Ustring::toCode.
*
* @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
Expand Down Expand Up @@ -92,7 +92,7 @@ public function main()

$this->parser->listInputs($char);

$code = base_convert((string) String::toCode($char), 10, $base);
$code = base_convert((string) Ustring::toCode($char), 10, $base);

echo $code, "\n";

Expand Down
177 changes: 89 additions & 88 deletions Documentation/En/Index.xyl

Large diffs are not rendered by default.

164 changes: 83 additions & 81 deletions Documentation/Fr/Index.xyl

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String;
namespace Hoa\Ustring;

use Hoa\Core;

/**
* Class \Hoa\String\Exception.
* Class \Hoa\Ustring\Exception.
*
* Extending the \Hoa\Core\Exception class.
*
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Hoa is a **modular**, **extensible** and **structured** set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds.

# Hoa\String ![state](http://central.hoa-project.net/State/String)
# Hoa\Ustring ![state](http://central.hoa-project.net/State/Ustring)

This library allows to manipulate UTF-8 strings easily with some search
algorithms.
Expand Down Expand Up @@ -32,14 +32,14 @@ search algorithm.

### Natural UTF-8 strings manipulation

The `Hoa\String\String` class allows to manipulate easily UTF-8 strings in a
The `Hoa\Ustring\Ustring` class allows to manipulate easily UTF-8 strings in a
very natural way. This class implements the `\ArrayAccess`, `\Countable` and
`\IteratorAggregate` interfaces. We will use the following examples:

```php
$french = new Hoa\String\String('Je t\'aime');
$arabic = new Hoa\String\String('أحبك');
$japanese = new Hoa\String\String('私はあなたを愛して');
$french = new Hoa\Ustring\Ustring('Je t\'aime');
$arabic = new Hoa\Ustring\Ustring('أحبك');
$japanese = new Hoa\Ustring\Ustring('私はあなたを愛して');
```

To get the first character, we will do:
Expand All @@ -57,9 +57,9 @@ modulo) indexes.

We note that it cares about text **direction**. Look at `$arabic[0]`, it returns
`أ` and not `ك`. To get the direction, we can use the
`Hoa\String\String::getDirection` method (which call the
`Hoa\String\String::getCharDirection` static method), it returns either
`Hoa\String\String::LTR` (`0`) or `Hoa\String\String::RTL` (`1`):
`Hoa\Ustring\Ustring::getDirection` method (which call the
`Hoa\Ustring\Ustring::getCharDirection` static method), it returns either
`Hoa\Ustring\Ustring::LTR` (`0`) or `Hoa\Ustring\Ustring::RTL` (`1`):

```php
var_dump(
Expand All @@ -70,7 +70,7 @@ var_dump(
```

Text direction is also important for the `append`, `prepend`, `pad`… methods on
`Hoa\String\String` for example.
`Hoa\Ustring\Ustring` for example.

To get the length of a string, we can use the `count` function:

Expand Down Expand Up @@ -102,21 +102,21 @@ Again, text direction is useful here. For `$arabic`, the iteration is done from
right to left.

Some static methods are helpful, such as `fromCode`, `toCode` or `isUtf8` on
`Hoa\String\String`:
`Hoa\Ustring\Ustring`:

```php
var_dump(
Hoa\String\String::fromCode(0x1a9), // string(2) "Ʃ"
Hoa\String\String::toCode('Ʃ'), // int(425) == 0x1a9
Hoa\String\String::isUtf8('Ʃ') // bool(true)
Hoa\Ustring\Ustring::fromCode(0x1a9), // string(2) "Ʃ"
Hoa\Ustring\Ustring::toCode('Ʃ'), // int(425) == 0x1a9
Hoa\Ustring\Ustring::isUtf8('Ʃ') // bool(true)
);
```

We can also transform any text into ASCII:

```php
$emoji = new Hoa\String\String('I ❤ Unicode');
$maths = new Hoa\String\String('∀ i ∈ ℕ');
$emoji = new Hoa\Ustring\Ustring('I ❤ Unicode');
$maths = new Hoa\Ustring\Ustring('∀ i ∈ ℕ');

echo
$emoji->toAscii(), "\n",
Expand All @@ -131,15 +131,15 @@ echo

### Search algorithm

The `Hoa\String\Search` implements search algorithms on strings.
The `Hoa\Ustring\Search` implements search algorithms on strings.

For example, the `Hoa\String\Search::approximated` method make a search by
For example, the `Hoa\Ustring\Search::approximated` method make a search by
approximated patterns (with *k* differences based upon the principle diagonal
monotony). If we search the word `GATAA` in `CAGATAAGAGAA` with 1 difference, we
will do:

```php
$search = Hoa\String\Search::approximated(
$search = Hoa\Ustring\Search::approximated(
$haystack = 'CAGATAAGAGAA',
$needle = 'GATAA',
$k = 1
Expand Down
4 changes: 2 additions & 2 deletions Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String;
namespace Hoa\Ustring;

/**
* Class \Hoa\String\Search.
* Class \Hoa\Ustring\Search.
*
* Some algorithms about search in strings.
*
Expand Down
6 changes: 3 additions & 3 deletions Test/Unit/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String\Test\Unit;
namespace Hoa\Ustring\Test\Unit;

use Hoa\String as LUT;
use Hoa\Ustring as LUT;
use Hoa\Test;

/**
* Class \Hoa\String\Test\Unit\Issue.
* Class \Hoa\Ustring\Test\Unit\Issue.
*
* Test suite of detected issues.
*
Expand Down
6 changes: 3 additions & 3 deletions Test/Unit/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String\Test\Unit;
namespace Hoa\Ustring\Test\Unit;

use Hoa\String as LUT;
use Hoa\Ustring as LUT;
use Hoa\Test;

/**
* Class \Hoa\String\Test\Unit\Search.
* Class \Hoa\Ustring\Test\Unit\Search.
*
* Test suite of the search algorithms.
*
Expand Down
12 changes: 6 additions & 6 deletions Test/Unit/String.php → Test/Unit/Ustring.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

namespace Hoa\String\Test\Unit;
namespace Hoa\Ustring\Test\Unit;

use Hoa\String as LUT;
use Hoa\Ustring as LUT;
use Hoa\Test;

/**
* Class \Hoa\String\Test\Unit\String.
* Class \Hoa\Ustring\Test\Unit\Ustring.
*
* Test suite of the string class.
*
* @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
class String extends Test\Unit\Suite
class Ustring extends Test\Unit\Suite
{
public function case_no_mbstring()
{
Expand All @@ -60,7 +60,7 @@ public function case_no_mbstring()
->exception(function () {
new LUT();
})
->isInstanceOf('Hoa\String\Exception');
->isInstanceOf('Hoa\Ustring\Exception');
}

public function case_append_ltr()
Expand Down Expand Up @@ -924,7 +924,7 @@ public function case_to_ascii_no_transliterator_no_normalizer()
->exception(function () use ($string) {
$string->toAscii();
})
->isInstanceOf('Hoa\String\Exception');
->isInstanceOf('Hoa\Ustring\Exception');
}

public function case_to_ascii_no_transliterator_no_normalizer_try()
Expand Down
Loading

0 comments on commit 0278566

Please sign in to comment.