diff --git a/.gitignore b/.gitignore index 9f7bfd4..ad837b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,18 @@ -vendor +# Ignore common macOS files and directories +**/.DS_Store + +# Ignore automatically generated files and directories /vendor/ /.fleet /.idea /.vscode -/.DS_Store + + +# Ignore Composer generated directory and files +/vendor + +# Ignore development tool generated files and directories .fleet .idea .vscode -.DS_Store composer.lock \ No newline at end of file diff --git a/README.md b/README.md index fc6bdf5..04a6192 100644 --- a/README.md +++ b/README.md @@ -41,16 +41,16 @@ To obtain the current list of languages with support, execute the following comm ```php SpellNumber::getAllLocales(); // array [ -// 'de', // German from Germany -// 'en', // English from the United States -// 'es', // Spanish from Spain -// 'pt', // Portuguese from Portugal -// 'fr', // French from France -// 'it', // Italian from Italy -// 'ro', // Romanian from Romania -// 'fa', // Farsi from Iran -// 'hi', // Hindi from India -// 'pl', // Polish from Poland +// 'de', // German +// 'en', // English +// 'es', // Spanish +// 'pt', // Portuguese +// 'fr', // French +// 'it', // Italian +// 'ro', // Romanian +// 'fa', // Farsi +// 'hi', // Hindi +// 'pl', // Polish // ] ``` @@ -121,7 +121,6 @@ SpellNumber::float('12345.23')->locale('es')->toLetters(); ``` ## Creator - - 🇨🇴 Raúl Mauricio Uñate Castro - Email: raulmauriciounate@gmail.com @@ -136,6 +135,8 @@ This project is under the [MIT License](https://choosealicense.com/licenses/mit/ 🌟 Support My Projects! 🚀 +[![Become a Sponsor](https://img.shields.io/badge/-Become%20a%20Sponsor-green?style=for-the-badge&logo=github)](https://github.com/sponsors/rmunate) + Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨ If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩‍💻👨‍💻 diff --git a/README_SPANISH.md b/README_SPANISH.md index e9d724c..54b27ed 100644 --- a/README_SPANISH.md +++ b/README_SPANISH.md @@ -41,16 +41,16 @@ Para obtener la lista actual de idiomas compatibles, ejecuta el siguiente comand ```php SpellNumber::getAllLocales(); // array [ -// 'de', // German from Germany -// 'en', // English from the United States -// 'es', // Spanish from Spain -// 'pt', // Portuguese from Portugal -// 'fr', // French from France -// 'it', // Italian from Italy -// 'ro', // Romanian from Romania -// 'fa', // Farsi from Iran -// 'hi', // Hindi from India -// 'pl', // Polish from Poland +// 'de', // German +// 'en', // English +// 'es', // Spanish +// 'pt', // Portuguese +// 'fr', // French +// 'it', // Italian +// 'ro', // Romanian +// 'fa', // Farsi +// 'hi', // Hindi +// 'pl', // Polish // ] ``` @@ -109,7 +109,6 @@ SpellNumber::value(100.65)->locale('pl')->currency('złotych')->fraction('groszy ``` #### Otros Métodos de Inicialización - Para admitir la versión 1.X, se mantienen los siguientes métodos de inicialización. ```php @@ -121,7 +120,6 @@ SpellNumber::float('12345.23')->locale('es')->toLetters(); ``` ## Creador - - 🇨🇴 Raúl Mauricio Uñate Castro - Correo Electrónico: raulmauriciounate@gmail.com @@ -133,13 +131,12 @@ SpellNumber::float('12345.23')->locale('es')->toLetters(); - [Jens Twesmann](https://github.com/jetwes) (German Language) ## Licencia - Este proyecto se encuentra bajo la [Licencia MIT](https://choosealicense.com/licenses/mit/). 🌟 ¡Apoya Mis Proyectos! 🚀 -Realiza cualquier contribución que consideres adecuada; el código es completamente tuyo. Juntos, podemos hacer cosas increíbles y mejorar el mundo del desarrollo. Tu apoyo es invaluable. ✨ +[![Hazte patrocinador](https://img.shields.io/badge/-Házte%20patrocinador-green?style=for-the-badge&logo=github)](https://github.com/sponsors/rmunate) -Si tienes ideas, suger +Realiza cualquier contribución que consideres adecuada; el código es completamente tuyo. Juntos, podemos hacer cosas increíbles y mejorar el mundo del desarrollo. Tu apoyo es invaluable. ✨ -encias o simplemente quieres colaborar, ¡estamos abiertos a todo! Únete a nuestra comunidad y sé parte de nuestro camino hacia el éxito. 🌐👩‍💻👨‍💻 +Si tienes ideas, sugerencias o simplemente quieres colaborar, ¡estamos abiertos a todo! Únete a nuestra comunidad y sé parte de nuestro camino hacia el éxito. 🌐👩‍💻👨‍💻 diff --git a/composer.json b/composer.json index 861b107..5b508b7 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,6 @@ "números", "numbers", "spell", - "altum", "rmunate" ], "homepage": "https://github.com/rmunate/SpellNumber", @@ -41,6 +40,11 @@ "name": "Siros Fakhri", "homepage": "https://github.com/sirosfakhri", "role": "developer" + }, + { + "name": "Jens Twesmann", + "homepage": "https://github.com/jetwes", + "role": "developer" } ], "require": { diff --git a/src/Exceptions/SpellNumberExceptions.php b/src/Exceptions/SpellNumberExceptions.php index be88295..0b495eb 100644 --- a/src/Exceptions/SpellNumberExceptions.php +++ b/src/Exceptions/SpellNumberExceptions.php @@ -23,6 +23,6 @@ final class SpellNumberExceptions extends Exception */ public static function create($message, $code = 0, Throwable $previous = null) { - return new self('SpellNumber - '.$message, $code, $previous); + return new self('Rmunate\Utilities\SpellNumber::class - '.$message, $code, $previous); } } diff --git a/src/Langs/Langs.php b/src/Langs/Langs.php index 70bf7d3..d82f4ec 100644 --- a/src/Langs/Langs.php +++ b/src/Langs/Langs.php @@ -62,7 +62,7 @@ final class Langs * Get the language locale used in Laravel application. * If the locale is supported in ISO 639-1 format, return it. Otherwise, return the default. */ - public static function getLocaleLaravel(): string + public static function getLocaleLaravel() { $localeLaravel = App::getLocale(); $iso639_1 = substr($localeLaravel, 0, 2); diff --git a/src/Miscellaneous/Replaces.php b/src/Miscellaneous/Replaces.php index 66604e7..bc1dbce 100644 --- a/src/Miscellaneous/Replaces.php +++ b/src/Miscellaneous/Replaces.php @@ -71,7 +71,7 @@ final class Replaces * * @return string The adjusted text with the replacements performed. */ - public static function locale(string $value, string $locale, string $current): string + public static function locale(string $value, string $locale, string $current) { // Parameter validation if (empty($value) || empty($locale) || empty($current)) { diff --git a/src/Miscellaneous/Utilities.php b/src/Miscellaneous/Utilities.php index 2d9ba7b..a5766dc 100644 --- a/src/Miscellaneous/Utilities.php +++ b/src/Miscellaneous/Utilities.php @@ -16,7 +16,7 @@ final class Utilities * * @return bool True if the extension is loaded, false otherwise. */ - public static function validateExtension(string $name): bool + public static function validateExtension(string $name) { return extension_loaded($name); } @@ -28,7 +28,7 @@ public static function validateExtension(string $name): bool * * @return bool True if the value is numeric, false otherwise. */ - public static function isValidNumber($value): bool + public static function isValidNumber($value) { return is_numeric($value); } @@ -40,7 +40,7 @@ public static function isValidNumber($value): bool * * @return bool True if the value is a string, false otherwise. */ - public static function isValidString($value): bool + public static function isValidString($value) { return is_string($value); } @@ -52,7 +52,7 @@ public static function isValidString($value): bool * * @return bool True if the value is an integer, false otherwise. */ - public static function isValidInteger($value): bool + public static function isValidInteger($value) { return is_int($value); } @@ -64,7 +64,7 @@ public static function isValidInteger($value): bool * * @return bool True if the value is a float, false otherwise. */ - public static function isValidDouble($value): bool + public static function isValidDouble($value) { return is_float($value); } @@ -76,7 +76,7 @@ public static function isValidDouble($value): bool * * @return bool True if the value does not exceed the maximum, false otherwise. */ - public static function isNotExceedMax($value): bool + public static function isNotExceedMax($value) { //Validate scientific notation. if (preg_match('/[+\-E]/i', strval($value)) > 0) { @@ -105,7 +105,7 @@ public static function isNotExceedMax($value): bool * * @return bool True if the locale is valid and supported, false otherwise. */ - public static function isValidLocale($locale): bool + public static function isValidLocale($locale) { return in_array($locale, Langs::LOCALES); } @@ -117,7 +117,7 @@ public static function isValidLocale($locale): bool * * @return string The connector for the given locale. */ - public static function connector($locale): string + public static function connector($locale) { $connector = Langs::LOCALES_CONNECTORS; @@ -131,7 +131,7 @@ public static function connector($locale): string * * @return string The money connector for the given locale. */ - public static function connectorMoney($locale): string + public static function connectorMoney($locale) { $connector = Langs::LOCALES_CONNECTORS_MONEY; diff --git a/src/SpellNumber.php b/src/SpellNumber.php index 60a1889..460eef9 100644 --- a/src/SpellNumber.php +++ b/src/SpellNumber.php @@ -53,7 +53,7 @@ public function __construct($value, string $type) * * @return SpellNumber The SpellNumber instance with the fractional value added. */ - public function fractional(int $value): SpellNumber + public function fractional(int $value) { if ($this->type == 'double') { throw SpellNumberExceptions::create('The value used initially is already a float value, it is not possible to add other decimals to it.'); @@ -75,7 +75,7 @@ public function fractional(int $value): SpellNumber * * @return SpellNumber The SpellNumber instance with the updated locale. */ - public function locale(string $locale): SpellNumber + public function locale(string $locale) { if (!Utilities::isValidLocale($locale)) { throw SpellNumberExceptions::create('The provided value is not valid. You can use the getAllLocales() method to see the available options.'); @@ -92,7 +92,7 @@ public function locale(string $locale): SpellNumber * * @return SpellNumber The SpellNumber instance with the updated currency. */ - public function currency(string $currency): SpellNumber + public function currency(string $currency) { $this->currency = Str::title($currency); @@ -106,7 +106,7 @@ public function currency(string $currency): SpellNumber * * @return SpellNumber The SpellNumber instance with the updated fraction. */ - public function fraction(string $fraction): SpellNumber + public function fraction(string $fraction) { $this->fraction = Str::title($fraction); @@ -118,7 +118,7 @@ public function fraction(string $fraction): SpellNumber * * @return string The textual representation of the numeric value. */ - public function toLetters(): string + public function toLetters() { return ($this->type == 'integer') ? Str::title($this->integerToLetters()) : Str::title($this->doubleToLetters()); } @@ -128,7 +128,7 @@ public function toLetters(): string * * @return string The textual representation of the money value. */ - public function toMoney(): string + public function toMoney() { return ($this->type == 'integer') ? Str::title($this->integerToMoney()) : Str::title($this->doubleToMoney()); } @@ -138,7 +138,7 @@ public function toMoney(): string * * @return string The textual representation of the integer numeric value. */ - private function integerToLetters(): string + private function integerToLetters() { $formatter = NumberFormatterWrapper::format($this->value, $this->locale); @@ -150,7 +150,7 @@ private function integerToLetters(): string * * @return string The textual representation of the double numeric value. */ - private function doubleToLetters(): string + private function doubleToLetters() { $parts = explode('.', $this->value); $letters1 = NumberFormatterWrapper::format($parts[0], $this->locale); @@ -164,7 +164,7 @@ private function doubleToLetters(): string * * @return string The money representation of the integer numeric value. */ - private function integerToMoney(): string + private function integerToMoney() { $letters = NumberFormatterWrapper::format($this->value, $this->locale); $letters = Replaces::locale($letters, $this->locale, $this->currency); @@ -177,7 +177,7 @@ private function integerToMoney(): string * * @return string The money representation of the double numeric value. */ - private function doubleToMoney(): string + private function doubleToMoney() { $parts = explode('.', $this->value); $letters1 = NumberFormatterWrapper::format($parts[0], $this->locale); diff --git a/src/Validator/SpellNumberValidator.php b/src/Validator/SpellNumberValidator.php index e7972c3..5a4f4d8 100644 --- a/src/Validator/SpellNumberValidator.php +++ b/src/Validator/SpellNumberValidator.php @@ -90,7 +90,7 @@ public function float() * * @return mixed The result of the validation. */ - public function result(): mixed + public function result() { return $this->response; } diff --git a/src/Validator/Traits/CommonValidate.php b/src/Validator/Traits/CommonValidate.php index 366b13a..cd0870f 100644 --- a/src/Validator/Traits/CommonValidate.php +++ b/src/Validator/Traits/CommonValidate.php @@ -12,7 +12,7 @@ trait CommonValidate * * @throws SpellNumberExceptions If the "Intl" extension is not installed or not available. */ - private function validateExtension(): bool + private function validateExtension() { // Check if the intl extension is installed. if (!Utilities::validateExtension('Intl')) { @@ -27,7 +27,7 @@ private function validateExtension(): bool * * @throws SpellNumberExceptions If the supplied value is not valid (not integer or float). */ - private function validateNumeric(): bool + private function validateNumeric() { if (!Utilities::isValidNumber($this->value)) { throw SpellNumberExceptions::create('The supplied value is not valid. It must be of type integer or float (double).'); @@ -41,7 +41,7 @@ private function validateNumeric(): bool * * @throws SpellNumberExceptions If the supplied value is not a valid integer. */ - private function validateInteger(): bool + private function validateInteger() { if (!Utilities::isValidInteger($this->value)) { throw SpellNumberExceptions::create('The supplied value is not valid. It must be of type integer.'); @@ -55,7 +55,7 @@ private function validateInteger(): bool * * @throws SpellNumberExceptions If the supplied value is not a valid string. */ - private function validateString(): bool + private function validateString() { if (!Utilities::isValidString($this->value)) { throw SpellNumberExceptions::create('The supplied value is not valid. It must be of type String.'); @@ -69,7 +69,7 @@ private function validateString(): bool * * @throws SpellNumberExceptions If the entered value exceeds the maximum allowed value. */ - private function validateMaximum(): bool + private function validateMaximum() { if (!Utilities::isNotExceedMax($this->value)) { throw SpellNumberExceptions::create('The value entered is too large and has been converted to scientific notation which prevents processing.'); @@ -83,7 +83,7 @@ private function validateMaximum(): bool * * @return string Returns "integer" if the value is a valid integer, otherwise "double". */ - private function validateType(): string + private function validateType() { return Utilities::isValidInteger($this->value) ? 'integer' : 'double'; } diff --git a/src/Wrappers/NumberFormatterWrapper.php b/src/Wrappers/NumberFormatterWrapper.php index 15f7b8b..ebdfd8f 100644 --- a/src/Wrappers/NumberFormatterWrapper.php +++ b/src/Wrappers/NumberFormatterWrapper.php @@ -19,7 +19,7 @@ final class NumberFormatterWrapper * * @return string|null The spelled-out representation of the number, or null on failure. */ - public static function format(float|int $value, string $locale = null): ?string + public static function format(float|int $value, string $locale = null) { // If no locale is provided, use the default locale from the environment. $locale = $locale ?: Langs::getLocaleLaravel();