MDL-82571 customfield_number: small coding style cleanup.

This commit is contained in:
Paul Holden 2024-09-04 10:14:25 +01:00
parent cbcb9d071f
commit 865e8f3e90
No known key found for this signature in database
GPG key ID: A81A96D6045F6164
2 changed files with 7 additions and 7 deletions

View file

@ -143,7 +143,7 @@ class field_controller extends \core_customfield\field_controller {
* @return string|null
*/
public function prepare_field_for_display(mixed $value, ?context $context = null): ?string {
if ((float)$value == 0) {
if ((float) $value == 0) {
$value = $this->get_configdata_property('displaywhenzero');
if ((string) $value === '') {
return null;

View file

@ -132,17 +132,17 @@ final class data_controller_test extends advanced_testcase {
'Export float value' => [42, 42.0, [
'decimalplaces' => 2,
'display' => '{value}',
'displaywhenzero' => 0],
],
'displaywhenzero' => 0,
]],
'Export value with a prefix' => [10, '$ 10.00', [
'decimalplaces' => 2,
'display' => $template,
'displaywhenzero' => 0],
],
'displaywhenzero' => 0,
]],
'Export value when zero' => [0, 'Unknown', [
'display' => '{value}',
'displaywhenzero' => $whenzero],
],
'displaywhenzero' => $whenzero,
]],
];
}