-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ICU instead of iconv extension. Change readme and API.
- Loading branch information
1 parent
a556232
commit 5cb7506
Showing
14 changed files
with
70 additions
and
42 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -8,8 +8,6 @@ | |
* Class Facade. | ||
* | ||
* @author Eugene Dzhumak <[email protected]> | ||
* | ||
* @version 2.0.0 | ||
*/ | ||
class Facade extends BaseFacade | ||
{ | ||
|
@@ -18,6 +16,6 @@ class Facade extends BaseFacade | |
*/ | ||
public static function getFacadeAccessor() | ||
{ | ||
return 'Transliteration'; | ||
return 'Transliterator'; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
|
||
/** | ||
* Class Map. | ||
* | ||
* @author Eugene Dzhumak <[email protected]> | ||
* @version 2.0.0 | ||
*/ | ||
abstract class Map | ||
{ | ||
|
@@ -16,4 +16,4 @@ abstract class Map | |
|
||
public const DEFAULT = 'common'; | ||
public const GOST_7_79_2000 = 'GOST_7.79.2000'; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -8,8 +8,6 @@ | |
* Class ServiceProvider. | ||
* | ||
* @author Eugene Dzhumak <[email protected]> | ||
* | ||
* @version 2.0.0 | ||
*/ | ||
class ServiceProvider extends BaseServiceProvider | ||
{ | ||
|
@@ -34,7 +32,7 @@ public function register() | |
|
||
$this->mergeConfigFrom($configPath, 'transliterate'); | ||
|
||
$this->app->bind('Transliteration', function ($app) { | ||
$this->app->bind('Transliterator', function ($app) { | ||
return new Transliterator(); | ||
}); | ||
} | ||
|
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 |
---|---|---|
|
@@ -8,8 +8,6 @@ | |
* Class Transformer. | ||
* | ||
* @author Eugene Dzhumak <[email protected]> | ||
* | ||
* @version 1.0.0 | ||
*/ | ||
final class Transformer | ||
{ | ||
|
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 |
---|---|---|
|
@@ -10,11 +10,9 @@ | |
* Feel free to change it. | ||
* Either by pull request or forking. | ||
* | ||
* Class Transliteration | ||
* Class Transliterator | ||
* | ||
* @author Eugene Dzhumak <[email protected]> | ||
* | ||
* @version 2.0.0 | ||
*/ | ||
class Transliterator | ||
{ | ||
|
@@ -34,7 +32,10 @@ public function __construct(string $lang = null, string $map = null) | |
} | ||
|
||
/** | ||
* @param string $lang | ||
* Change transliterating text language. | ||
* | ||
* @param string $lang One of the Map::LANG_* constants or custom language. | ||
* | ||
* @return Transliterator | ||
*/ | ||
public function from(string $lang): self | ||
|
@@ -45,7 +46,10 @@ public function from(string $lang): self | |
} | ||
|
||
/** | ||
* @param string $map | ||
* Change transliteration map | ||
* | ||
* @param string $map Name of the transliteration map. | ||
* | ||
* @return Transliterator | ||
*/ | ||
public function useMap(string $map): self | ||
|
@@ -67,7 +71,7 @@ public function make(string $text): string | |
$map = $this->getMap(); | ||
$transliterated = str_replace(array_keys($map), array_values($map), $text); | ||
|
||
if (config('transliterate.remove_accents', false) === true) { | ||
if (true === config('transliterate.remove_accents', false)) { | ||
$transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII'); | ||
$transliterated = $transliterator->transliterate($transliterated); | ||
} | ||
|
@@ -79,6 +83,7 @@ public function make(string $text): string | |
* Create a slug by converting and removing all non-ascii characters. | ||
* | ||
* @param string $text | ||
* | ||
* @return string | ||
*/ | ||
public function slugify(string $text): string | ||
|
@@ -116,7 +121,7 @@ private function getMap(): array | |
throw new \InvalidArgumentException("The transliteration map '${path}' doesn't exist"); | ||
} | ||
|
||
/** @noinspection PhpIncludeInspection */ | ||
/* @noinspection PhpIncludeInspection */ | ||
return require $path; | ||
} | ||
|
||
|
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
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
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
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
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
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