Skip to content

Commit

Permalink
add Number::toShort mixin method
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Sep 9, 2024
1 parent 41ff21f commit 241f12b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function register()
\Illuminate\Support\Arr::mixin(new \OpenSoutheners\ExtendedLaravel\Support\Arr);
\Illuminate\Support\Str::mixin(new \OpenSoutheners\ExtendedLaravel\Support\Str);
\Illuminate\Support\Stringable::mixin(new \OpenSoutheners\ExtendedLaravel\Support\Stringable);
\Illuminate\Support\Number::mixin(new \OpenSoutheners\ExtendedLaravel\Support\Number);
\Illuminate\Support\Facades\Storage::mixin(new \OpenSoutheners\ExtendedLaravel\Support\Storage);
\Illuminate\Support\Collection::mixin(new \OpenSoutheners\ExtendedLaravel\Support\Collection);
\Illuminate\Events\Dispatcher::mixin(new \OpenSoutheners\ExtendedLaravel\Events\Dispatcher);
Expand Down
24 changes: 24 additions & 0 deletions src/Support/Number.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace OpenSoutheners\ExtendedLaravel\Support;

use Closure;

use function OpenSoutheners\ExtendedPhp\Numbers\short_number;

/**
* This is NOT supposed to be used alone, use the main from Laravel framework
* instead as is the one this is extending with new methods.
*
* @mixin \Illuminate\Support\Number
*/
class Number
{
public function toShort(): Closure
{
/**
* Get shorter version of a big number if possible.
*/
return fn (int|float $number): string => short_number($number);
}
}

0 comments on commit 241f12b

Please sign in to comment.