Skip to content

Conversation

mboiev
Copy link
Collaborator

@mboiev mboiev commented Mar 6, 2020

No description provided.

*/
public function validate($v): bool
{
return strlen($v) == $this->length;
Copy link
Contributor

Choose a reason for hiding this comment

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

In PHP, it is a best practice to test with a strict comparison: !== and ===

*/
public function getMessage($v): string
{
return $this->message?:"'${$v}' is supposed to be exactly ".$this->length." characters long";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change supposed to 'expected'?

)
{
if($length <0)
throw new InvalidArgumentException();
Copy link
Contributor

Choose a reason for hiding this comment

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

When throwing an exception, a message should always be provided in order to inform the user why the exception was thrown without needing to look at the source code.

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