Skip to content

Conversation

@sunnysideup
Copy link
Contributor

This is just an idea, be curious to see if this would be acceptable.

You can then write in your template:

$MyInt  = $MyInt.SpelledOut 

Which outputs:

7 = seven

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thank you for this contribution. It seems like a good idea to me - just a few things to tidy up

}


public function SpelledOut()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a phpdoc comment explaining what the method does.

}


public function SpelledOut()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function SpelledOut()
public function SpelledOut(): string

People will expect a string, but NumberFormatter::format() can return false.

This method should return an empty string in the event the format() method returns false.

Comment on lines +70 to +71
$v = $this->prepValueForDB($this->value);
return (new NumberFormatter(i18n::get_locale(), NumberFormatter::SPELLOUT))->format($v);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$v = $this->prepValueForDB($this->value);
return (new NumberFormatter(i18n::get_locale(), NumberFormatter::SPELLOUT))->format($v);
$value = $this->prepValueForDB($this->value);
$formatter = new NumberFormatter(i18n::get_locale(), NumberFormatter::SPELLOUT);
return $formatter->format($value);

Please don't use single-letter variables, nor wrap instantiation in quotes.


public function SpelledOut()
{
$v = $this->prepValueForDB($this->value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you calling prepValueForDB() first? e.g. DBInt::Formatted() doesn't do that.

@GuySartorelli
Copy link
Member

Please also create an issue for this PR and link them to each other as per our contribution guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants