Skip to content

Commit 6aafff0

Browse files
committed
fix: add missing CLIRequest::getLocale()
Call to undefined method CodeIgniter\HTTP\CLIRequest::getLocale()
1 parent 5e7b4fe commit 6aafff0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

system/HTTP/CLIRequest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace CodeIgniter\HTTP;
1313

1414
use Config\App;
15+
use Locale;
1516
use RuntimeException;
1617

1718
/**
@@ -280,4 +281,13 @@ private function returnNullOrEmptyArray($index)
280281
{
281282
return ($index === null || is_array($index)) ? [] : null;
282283
}
284+
285+
/**
286+
* Gets the current locale, with a fallback to the default
287+
* locale if none is set.
288+
*/
289+
public function getLocale(): string
290+
{
291+
return Locale::getDefault();
292+
}
283293
}

tests/system/HTTP/CLIRequestTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,9 @@ public function testGetGetPost()
611611
{
612612
$this->assertSame([], $this->request->getGetPost());
613613
}
614+
615+
public function testGetLocale()
616+
{
617+
$this->assertSame('en', $this->request->getLocale());
618+
}
614619
}

0 commit comments

Comments
 (0)