-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0344498
Showing
14 changed files
with
815 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# ---------------------- | ||
# The FPM base container | ||
# ---------------------- | ||
FROM php:8.1-cli-alpine AS dev | ||
|
||
RUN apk add --no-cache --virtual .build-deps \ | ||
$PHPIZE_DEPS | ||
|
||
# Cleanup apk cache and temp files | ||
RUN rm -rf /var/cache/apk/* /tmp/* | ||
|
||
# ---------------------- | ||
# Composer install step | ||
# ---------------------- | ||
|
||
# Get latest Composer | ||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer | ||
|
||
# ---------------------- | ||
# The FPM production container | ||
# ---------------------- | ||
FROM dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
* text=auto | ||
|
||
/.docker export-ignore | ||
/.github export-ignore | ||
/tests export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/CODE_OF_CONDUCT.md export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/docker-compose.yaml export-ignore | ||
/phpunit.xml.dist export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: tests | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
php: [ 7.4, 8.0, 8.1, 8.2 ] | ||
dependency-version: [ prefer-lowest, prefer-stable ] | ||
|
||
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.composer/cache/files | ||
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: mbstring | ||
tools: composer:v2 | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer install --no-interaction | ||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction | ||
- name: Execute tests | ||
run: vendor/bin/phpunit --testdox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/.idea/ | ||
/vendor/ | ||
.phpunit.result.cache | ||
composer.lock | ||
phpunit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023, Anton Komarev <anton@komarev.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# PHP Unicode | ||
|
||
<p align="center"> | ||
<a href="https://github.com/cybercog/php-unicode/releases"><img src="https://img.shields.io/github/release/cybercog/php-unicode.svg?style=flat-square" alt="Releases"></a> | ||
<a href="https://github.com/cybercog/php-unicode/actions/workflows/tests.yml"><img src="https://img.shields.io/github/actions/workflow/status/cybercog/php-unicode/tests.yml?style=flat-square" alt="Build"></a> | ||
<a href="https://github.com/cybercog/php-unicode/blob/master/LICENSE"><img src="https://img.shields.io/github/license/cybercog/php-unicode.svg?style=flat-square" alt="License"></a> | ||
</p> | ||
|
||
## Introduction | ||
|
||
Streamline Unicode strings and characters (code points) manipulations. Object oriented implementation. | ||
|
||
## Installation | ||
|
||
Pull in the package through Composer. | ||
|
||
```shell | ||
composer require cybercog/php-unicode | ||
``` | ||
|
||
## Usage | ||
|
||
### Instantiate Unicode String | ||
|
||
```php | ||
$compositeCharacter = \Cog\Unicode\UnicodeString::of('Hello'); | ||
``` | ||
|
||
`UnicodeString` object will contain a list of Unicode characters. | ||
|
||
For example, the Unicode string "Hello" is represented by the code points: | ||
- U+0048 (H) | ||
- U+0065 (e) | ||
- U+006C (l) | ||
- U+006C (l) | ||
- U+006F (o) | ||
|
||
### Represent Unicode String | ||
|
||
```php | ||
$compositeCharacter = \Cog\Unicode\UnicodeString::of('Hello'); | ||
|
||
echo strval($compositeCharacter); // (string) "Hello" | ||
``` | ||
|
||
### Instantiate Unicode Character | ||
|
||
```php | ||
$character = \Cog\Unicode\Character::of('ÿ'); | ||
|
||
$character = \Cog\Unicode\Character::ofDecimal(255); | ||
|
||
$character = \Cog\Unicode\Character::ofHexadecimal('U+00FF'); | ||
|
||
$character = \Cog\Unicode\Character::ofHtmlEntity('ÿ'); | ||
|
||
$character = \Cog\Unicode\Character::ofXmlEntity('ÿ'); | ||
``` | ||
|
||
### Represent Unicode Character in any format | ||
|
||
```php | ||
$character = \Cog\Unicode\Character::of('ÿ'); | ||
|
||
echo strval($character); // (string) "ÿ" | ||
|
||
echo $character->toDecimal(); // (int) 255 | ||
|
||
echo $character->toHexadecimal(); // (string) "U+00FF" | ||
|
||
echo $character->toHtmlEntity(); // (string) "ÿ" | ||
|
||
echo $character->toXmlEntity(); // (string) "ÿ" | ||
``` | ||
|
||
## License | ||
|
||
- `PHP Unicode` package is open-sourced software licensed under the [MIT license](LICENSE) by [Anton Komarev]. | ||
|
||
## About CyberCog | ||
|
||
[CyberCog] is a Social Unity of enthusiasts. Research the best solutions in product & software development is our passion. | ||
|
||
- [Follow us on Twitter](https://twitter.com/cybercog) | ||
|
||
<a href="https://cybercog.su"><img src="https://cloud.githubusercontent.com/assets/1849174/18418932/e9edb390-7860-11e6-8a43-aa3fad524664.png" alt="CyberCog"></a> | ||
|
||
[Anton Komarev]: https://komarev.com | ||
[CyberCog]: https://cybercog.su |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "cybercog/php-unicode", | ||
"description": "PHP Unicode library", | ||
"type": "library", | ||
"license": "MIT", | ||
"keywords": [ | ||
"cog", | ||
"unicode", | ||
"code-point", | ||
"character", | ||
"composite-character", | ||
"symbol", | ||
"emoji", | ||
"html-entity", | ||
"xml-entity" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Anton Komarev", | ||
"email": "anton@komarev.com", | ||
"homepage": "https://komarev.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Cog\\Unicode\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Test\\Unit\\Cog\\Unicode\\": "test/" | ||
} | ||
}, | ||
"require": { | ||
"php": "^8.1", | ||
"ext-mbstring": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^10.0" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable" : true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: "3.9" | ||
services: | ||
app: | ||
container_name: php-unicode-lib | ||
image: php-unicode-lib | ||
build: | ||
context: ./ | ||
dockerfile: ./.docker/php/Dockerfile | ||
tty: true | ||
working_dir: /app | ||
volumes: | ||
- ./:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./test/Unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Oops, something went wrong.