Skip to content

Commit

Permalink
Merge pull request #11 from sunrise-php/release/v2.0.0
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
fenric authored Feb 1, 2021
2 parents f86b7e3 + dd852dc commit 473979b
Show file tree
Hide file tree
Showing 15 changed files with 306 additions and 354 deletions.
55 changes: 55 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
php71:
docker:
- image: circleci/php:7.1-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
php72:
docker:
- image: circleci/php:7.2-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
php73:
docker:
- image: circleci/php:7.3-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
php74:
docker:
- image: circleci/php:7.4-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
php80:
docker:
- image: circleci/php:8.0-cli-node-browsers
steps:
- checkout
- run: php -v
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
workflows:
version: 2
build:
jobs:
- php71
- php72
- php73
- php74
- php80
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

[*.php]
indent_style = tab

[*.yml]
indent_size = 2
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.php_cs.cache
.phpunit.result.cache
composer.lock
coverage.xml
phpcs.xml
phpunit.xml
vendor/
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ matrix:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4
- php: nightly
fast_finish: true

before_install:
Expand All @@ -13,4 +15,4 @@ before_install:
install:
- travis_retry composer install --no-interaction --prefer-source --no-suggest

script: vendor/bin/phpunit --colors=always --coverage-text
script: php vendor/bin/phpunit --colors=always --coverage-text
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 Anatoly Fenric
Copyright (c) 2018 Sunrise // PHP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
61 changes: 13 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Simple slugger for PHP 7.1+ based on ICU
# Simple slugger for PHP 7.1+ (incl. PHP8) based on ICU

[![Gitter](https://badges.gitter.im/sunrise-php/support.png)](https://gitter.im/sunrise-php/support)
[![Build Status](https://api.travis-ci.com/sunrise-php/slugger.svg?branch=master)](https://travis-ci.com/sunrise-php/slugger)
[![CodeFactor](https://www.codefactor.io/repository/github/sunrise-php/slugger/badge)](https://www.codefactor.io/repository/github/sunrise-php/slugger)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/slugger/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/slugger/?branch=master)
[![Build Status](https://circleci.com/gh/sunrise-php/slugger.svg?style=shield)](https://circleci.com/gh/sunrise-php/slugger)
[![Code Coverage](https://scrutinizer-ci.com/g/sunrise-php/slugger/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/slugger/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/sunrise/slugger/v/stable?format=flat)](https://packagist.org/packages/sunrise/slugger)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/slugger/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/slugger/?branch=master)
[![Total Downloads](https://poser.pugx.org/sunrise/slugger/downloads?format=flat)](https://packagist.org/packages/sunrise/slugger)
[![Latest Stable Version](https://poser.pugx.org/sunrise/slugger/v/stable?format=flat)](https://packagist.org/packages/sunrise/slugger)
[![License](https://poser.pugx.org/sunrise/slugger/license?format=flat)](https://packagist.org/packages/sunrise/slugger)

## Awards
Expand All @@ -15,7 +14,7 @@

## Installation

```
```bash
composer require sunrise/slugger
```

Expand All @@ -24,59 +23,25 @@ composer require sunrise/slugger
#### Russian to Latin (default)

```php
$slugger = new \Sunrise\Slugger\Slugger();
use Sunrise\Slugger\Slugger;

$slugger = new Slugger();

// "syesh-yeshche-etikh-myagkikh-frantsuzskikh-bulok-da-vypey-chayu"
// syesh-yeshche-etikh-myagkikh-frantsuzskikh-bulok-da-vypey-chayu
$slugger->slugify('Съешь ещё этих мягких французских булок, да выпей чаю');
```

#### Deutsch to Latin

```php
$slugger = new \Sunrise\Slugger\Slugger();
$slugger->setTransliteratorId('de-ASCII');
use Sunrise\Slugger\Slugger;

// "falsches-ueben-von-xylophonmusik-quaelt-jeden-groesseren-zwerg"
$slugger->slugify('Falsches Üben von Xylophonmusik quält jeden größeren Zwerg');
```

#### Only transliteration

```php
$slugger = new \Sunrise\Slugger\Slugger();
$slugger->setTransliteratorId('Hiragana-Latin');

// "irohanihoheto chirinuruwo wakayotareso tsunenaramu uwinookuyama kefukoete asakiyumemishi wehimosesu"
$slugger->transliterate('いろはにほへと ちりぬるを わかよたれそ つねならむ うゐのおくやま けふこえて あさきゆめみし ゑひもせす', '');
```
$slugger = new Slugger('de-ASCII');

#### Customization

```php
$slugger = new \Sunrise\Slugger\Slugger();
$slugger->setTransliteratorId('Greek-Latin/BGN');

// "takhisti alopix vafis psimeni yi dhraskelizi iper nothrou kinos"
$slugger->transliterate('Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός', 'Any-Latin; Latin-ASCII; Lower(); [^\x20\x30-\x39\x41-\x5A\x61-\x7A] Remove');
```

#### Using DI Container

```php
$di['slugger'] = function() : \Sunrise\Slugger\SluggerInterface {
$slugger = new \Sunrise\Slugger\Slugger();
$slugger->setTransliteratorId('de-ASCII');

return $slugger;
};

$di['slugger']->slugify('Zwölf große Boxkämpfer jagen Viktor quer über den Sylter Deich.');
// falsches-ueben-von-xylophonmusik-quaelt-jeden-groesseren-zwerg
$slugger->slugify('Falsches Üben von Xylophonmusik quält jeden größeren Zwerg');
```

## Api documentation

https://phpdoc.fenric.ru/

## Useful links

* http://site.icu-project.org/
Expand Down
32 changes: 22 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
{
"name": "sunrise/slugger",
"description": "Simple slugger for PHP 7.1+ based on ICU",
"keywords": ["fenric", "sunrise", "slugger", "translit", "icu"],
"homepage": "https://github.com/sunrise-php/slugger",
"description": "Simple slugger for PHP 7.1+ based on ICU",
"license": "MIT",
"authors": [{
"name": "Anatoly Fenric",
"email": "[email protected]",
"homepage": "https://anatoly.fenric.ru/"
}],
"keywords": [
"fenric",
"sunrise",
"slugger",
"translit",
"icu",
"php7",
"php8"
],
"authors": [
{
"name": "Anatoly Fenric",
"email": "[email protected]",
"homepage": "https://anatoly.fenric.ru/"
}
],
"require": {
"php": "^7.1",
"php": "^7.1|^8.0",
"ext-intl": "*"
},
"require-dev": {
"phpunit/phpunit": "7.5.6"
"phpunit/phpunit": "7.5.20|9.5.0",
"sunrise/coding-standard": "1.0.0"
},
"autoload": {
"psr-4": {
Expand All @@ -23,7 +34,8 @@
},
"scripts": {
"test": [
"phpunit --colors=always --coverage-text"
"phpunit --colors=always --coverage-text",
"phpcs"
]
}
}
7 changes: 7 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<ruleset name="Sunrise Coding Standard">
<rule ref="./vendor/sunrise/coding-standard/ruleset.xml"/>

<file>src</file>
<file>tests</file>
</ruleset>
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0"?>
<phpunit colors="true">
<phpunit colors="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Sunrise Slugger Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
use RuntimeException;

/**
* UnsupportedTransliteratorIdentifierException
* Exception
*/
class UnsupportedTransliteratorIdentifierException extends RuntimeException
{}
class Exception extends RuntimeException
{
}
10 changes: 3 additions & 7 deletions src/Exception/UnableToCreateTransliteratorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@

namespace Sunrise\Slugger\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnableToCreateTransliteratorException
*/
class UnableToCreateTransliteratorException extends RuntimeException
{}
class UnableToCreateTransliteratorException extends Exception
{
}
10 changes: 3 additions & 7 deletions src/Exception/UnableToTransliterateException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@

namespace Sunrise\Slugger\Exception;

/**
* Import classes
*/
use RuntimeException;

/**
* UnableToTransliterateException
*/
class UnableToTransliterateException extends RuntimeException
{}
class UnableToTransliterateException extends Exception
{
}
Loading

0 comments on commit 473979b

Please sign in to comment.