feat: allow instantiation of FormatPHP without config or messages#38
feat: allow instantiation of FormatPHP without config or messages#38
Conversation
bb339ef to
e751cf7
Compare
e751cf7 to
10cc0e8
Compare
|
Code Climate has analyzed commit 10cc0e8 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (80% is the threshold). This pull request will bring the total coverage in the repository to 97.1% (0.0% change). View more on Code Climate. |
|
|
||
| $formatphpWithoutMessages = new FormatPHP(); | ||
|
|
||
| $this->assertSame( |
There was a problem hiding this comment.
This primarily tests that FormatPHP uses the system locale to format the date in the message string, if a locale is not passed in via a Config instance.
| $this->config = $config; | ||
| $this->messages = $messages; | ||
| $this->messageFormat = new MessageFormat($config->getLocale()); | ||
| $this->config = $config ?? new Config(new Locale(PhpLocale::getDefault())); |
There was a problem hiding this comment.
I wonder if we should set defaults the rest of the way up, so this is just ?? new Config()... and Config has a default of new Locale() and Locale has a default of PhpLocale::getDefault()
Seems like a reasonable set of defaults, but I defer to you.
There was a problem hiding this comment.
It's a good idea. Thanks!
Description
Allow instantiation of
FormatPHPwithout configuration or message collection instances; FormatPHP will use the system's default locale, in this case.Product requirements and context
This allows for easier tinkering in
composer repl, since it eliminates the need to create locale, config, and message collection objects.How has this been tested?
PR Checklist