Skip to content

Commit

Permalink
Fix Support PHP8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunate authored and rmunate committed Sep 12, 2023
1 parent 398bab3 commit 1e5857e
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 61 deletions.
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ]
```

Expand Down Expand Up @@ -121,7 +121,6 @@ SpellNumber::float('12345.23')->locale('es')->toLetters();
```

## Creator

- 🇨🇴 Raúl Mauricio Uñate Castro
- Email: [email protected]

Expand All @@ -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! 🌐👩‍💻👨‍💻
29 changes: 13 additions & 16 deletions README_SPANISH.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ]
```

Expand Down Expand Up @@ -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
Expand All @@ -121,7 +120,6 @@ SpellNumber::float('12345.23')->locale('es')->toLetters();
```

## Creador

- 🇨🇴 Raúl Mauricio Uñate Castro
- Correo Electrónico: [email protected]

Expand All @@ -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. 🌐👩‍💻👨‍💻
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"números",
"numbers",
"spell",
"altum",
"rmunate"
],
"homepage": "https://github.com/rmunate/SpellNumber",
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/SpellNumberExceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Langs/Langs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Miscellaneous/Replaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
18 changes: 9 additions & 9 deletions src/Miscellaneous/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;

Expand All @@ -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;

Expand Down
20 changes: 10 additions & 10 deletions src/SpellNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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.');
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Validator/SpellNumberValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function float()
*
* @return mixed The result of the validation.
*/
public function result(): mixed
public function result()
{
return $this->response;
}
Expand Down
Loading

0 comments on commit 1e5857e

Please sign in to comment.