Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 926fcf0

Browse files
committedNov 17, 2023
Add a Number::of helper to create a Numberable object
1 parent a085301 commit 926fcf0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎src/Illuminate/Support/Number.php

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ class Number
1717
*/
1818
protected static $locale = 'en';
1919

20+
/**
21+
* Get a new numberable object from the given number.
22+
*
23+
* @param int|float $number
24+
* @return \Illuminate\Support\Numberable
25+
*/
26+
public static function of($number)
27+
{
28+
return new Numberable($number);
29+
}
30+
2031
/**
2132
* Format the given number according to the current locale.
2233
*

‎tests/Support/SupportNumberTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55
use Illuminate\Support\Number;
66
use PHPUnit\Framework\TestCase;
7+
use Illuminate\Support\Numberable;
78

89
class SupportNumberTest extends TestCase
910
{
11+
public function testOf()
12+
{
13+
$this->assertEquals(new Numberable(10), Number::of(10));
14+
}
15+
1016
public function testFormat()
1117
{
1218
$this->needsIntlExtension();

0 commit comments

Comments
 (0)