Skip to content

Commit 5abf54c

Browse files
committed
add isAffirmative() method
1 parent aea4d3f commit 5abf54c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Strings.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,16 @@ public function format(...$args): self
17081708
return $this;
17091709
}
17101710

1711+
/**
1712+
* Returns true if the string is affirmative, false otherwise.
1713+
*
1714+
* @return bool Returns TRUE on success or FALSE otherwise.
1715+
*/
1716+
public function isAffirmative(): bool
1717+
{
1718+
return (bool) mb_ereg_match('^(?:1|t(?:rue)?|y(?:es)?|ok(?:ay)?)$', $this->string);
1719+
}
1720+
17111721
/**
17121722
* Returns true if the string is date and it is valid, false otherwise.
17131723
*

0 commit comments

Comments
 (0)