Skip to content

Commit

Permalink
Fix typo in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed Jan 4, 2024
1 parent 90b45e6 commit 86eeb87
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ----------------------
# The FPM base container
# ----------------------
FROM php:7.4-fpm-alpine AS dev
FROM php:8.1-cli-alpine AS dev

RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS
Expand Down
85 changes: 0 additions & 85 deletions .docker/php/www.conf

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ composer require cybercog/php-unicode
$compositeCharacter = \Cog\Unicode\UnicodeString::of('Hello');
```

`UnicodeString` object with contain a list of Unicode characters.
`UnicodeString` object will contain a list of Unicode characters.

For example, the Unicode string "Hello" is represented by the code points:
- U+0048 (H)
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
}
},
"require": {
"php": "^7.4|^8.0",
"php": "^8.1",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.0|^10.0"
"phpunit/phpunit": "^10.0"
},
"config": {
"sort-packages": true
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ services:
build:
context: ./
dockerfile: ./.docker/php/Dockerfile
restart: unless-stopped
tty: true
working_dir: /app
volumes:
- ./:/app
- ./.docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
Expand Down
18 changes: 7 additions & 11 deletions src/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@

final class Character
{
private int $codePoint;

private function __construct(
int $codePoint
public readonly int $codePoint,
) {
$this->codePoint = $codePoint;

if ($codePoint < 0x0000 || $codePoint > 0x10FFFF) {
throw new \OutOfRangeException(
"Character code point value `$codePoint` is out of range",
Expand All @@ -30,7 +26,7 @@ private function __construct(
}

public static function of(
string $string
string $string,
): self {
if (mb_strlen($string) !== 1) {
throw new \InvalidArgumentException(
Expand All @@ -44,15 +40,15 @@ public static function of(
}

public static function ofDecimal(
int $decimal
int $decimal,
): self {
return new self(
$decimal,
);
}

public static function ofHexadecimal(
string $hexadecimal
string $hexadecimal,
): self {
if (preg_match('#^U\+[0-9A-Fa-f]{4,}$#', $hexadecimal) !== 1) {
throw new \InvalidArgumentException(
Expand All @@ -66,7 +62,7 @@ public static function ofHexadecimal(
}

public static function ofHtmlEntity(
string $htmlEntity
string $htmlEntity,
): self {
return self::of(
html_entity_decode(
Expand All @@ -77,7 +73,7 @@ public static function ofHtmlEntity(
}

public static function ofXmlEntity(
string $xmlEntity
string $xmlEntity,
): self {
return self::of(
html_entity_decode(
Expand Down Expand Up @@ -123,6 +119,6 @@ public function isCombining(): bool

// public function resolveCodePointType(): string
// {
// Graphic, Format, Control, Private-Use, Surrogate, Noncharacter, Reserved.
// // Graphic, Format, Control, Private-Use, Surrogate, Noncharacter, Reserved.
// }
}
16 changes: 9 additions & 7 deletions src/UnicodeString.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@

final class UnicodeString
{
private array $characterList;

/**
* @param list<Character> $characterList
*/
private function __construct(
array $characterList
public readonly array $characterList,
) {
$this->characterList = $characterList;
}

/**
* @param list<Character> $characterList
*/
public static function ofCharacterList(
array $characterList
array $characterList,
): self {

return new self(
$characterList,
);
}

public static function of(
string $string
string $string,
): self {
$charList = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);

Expand All @@ -47,6 +46,9 @@ public function __toString(): string
return implode('', $this->characterList);
}

/**
* @return list<Character> $characterList
*/
public function characterList(): array
{
return $this->characterList;
Expand Down
10 changes: 5 additions & 5 deletions test/Unit/CharacterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testItCanInstantiateOfCharacter(
int $decimal,
string $hexadecimal,
string $htmlEntity,
string $xmlEntity
string $xmlEntity,
): void {
$character = Character::of($char);

Expand Down Expand Up @@ -56,7 +56,7 @@ public function testItCanInstantiateOfDecimal(
int $decimal,
string $hexadecimal,
string $htmlEntity,
string $xmlEntity
string $xmlEntity,
): void {
$character = Character::ofDecimal($decimal);

Expand Down Expand Up @@ -88,7 +88,7 @@ public function testItCanInstantiateOfHexadecimal(
int $decimal,
string $hexadecimal,
string $htmlEntity,
string $xmlEntity
string $xmlEntity,
): void {
$character = Character::ofHexadecimal($hexadecimal);

Expand Down Expand Up @@ -120,7 +120,7 @@ public function testItCanInstantiateOfHtmlEntity(
int $decimal,
string $hexadecimal,
string $htmlEntity,
string $xmlEntity
string $xmlEntity,
): void {
$character = Character::ofHtmlEntity($htmlEntity);

Expand Down Expand Up @@ -152,7 +152,7 @@ public function testItCanInstantiateOfXmlEntity(
int $decimal,
string $hexadecimal,
string $htmlEntity,
string $xmlEntity
string $xmlEntity,
): void {
if ($xmlEntity === '&#x0;') {
$this->markTestSkipped('XML does not have NULL value');
Expand Down
6 changes: 3 additions & 3 deletions test/Unit/UnicodeStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testBasicChars(): void

$text = UnicodeString::of($string);

$characterList = $text->characterList();
$characterList = $text->characterList;
$this->assertSame('M', strval($characterList[0]));
$this->assertSame('a', strval($characterList[1]));
$this->assertSame('r', strval($characterList[2]));
Expand Down Expand Up @@ -52,7 +52,7 @@ public function testCombiningChars(): void

$text = UnicodeString::of($string);

$characterList = $text->characterList();
$characterList = $text->characterList;
$this->assertSame('Á̀', strval($characterList[0]));
$this->assertSame('', strval($characterList[1]));
$this->assertSame('', strval($characterList[2]));
Expand All @@ -67,7 +67,7 @@ public function testEmojiCombiningChars(): void

$text = UnicodeString::of($string);

$characterList = $text->characterList();
$characterList = $text->characterList;
$this->assertSame('👨', strval($characterList[0]));
$this->assertSame('👩', strval($characterList[1]));
$this->assertSame('👧', strval($characterList[2]));
Expand Down

0 comments on commit 86eeb87

Please sign in to comment.