Skip to content

Commit

Permalink
Fix: Use boolean expressions (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Sep 2, 2023
1 parent b048b4a commit 7a06315
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Faker/Core/Version.php
Expand Up @@ -25,8 +25,8 @@ public function semver(bool $preRelease = false, bool $build = false): string
mt_rand(0, 9),
mt_rand(0, 99),
mt_rand(0, 99),
$preRelease && mt_rand(0, 1) ? '-' . $this->semverPreReleaseIdentifier() : '',
$build && mt_rand(0, 1) ? '+' . $this->semverBuildIdentifier() : '',
$preRelease && mt_rand(0, 1) === 1 ? '-' . $this->semverPreReleaseIdentifier() : '',
$build && mt_rand(0, 1) === 1 ? '+' . $this->semverBuildIdentifier() : '',
);
}

Expand All @@ -37,7 +37,7 @@ private function semverPreReleaseIdentifier(): string
{
$ident = Helper::randomElement($this->semverCommonPreReleaseIdentifiers);

if (!mt_rand(0, 1)) {
if (mt_rand(0, 1) !== 1) {
return $ident;
}

Expand All @@ -49,7 +49,7 @@ private function semverPreReleaseIdentifier(): string
*/
private function semverBuildIdentifier(): string
{
if (mt_rand(0, 1)) {
if (mt_rand(0, 1) === 1) {
// short git revision syntax: https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection
return substr(sha1(Helper::lexify('??????')), 0, 7);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Extension/Helper.php
Expand Up @@ -83,7 +83,7 @@ public static function lexify(string $string): string
public static function bothify(string $string): string
{
$string = self::replaceWildcard($string, '*', static function () {
return mt_rand(0, 1) ? '#' : '?';
return mt_rand(0, 1) === 1 ? '#' : '?';
});

return static::lexify(static::numerify($string));
Expand Down
2 changes: 1 addition & 1 deletion src/Faker/Provider/Base.php
Expand Up @@ -491,7 +491,7 @@ public static function lexify($string = '????')
public static function bothify($string = '## ??')
{
$string = self::replaceWildcard($string, '*', static function () {
return mt_rand(0, 1) ? '#' : '?';
return mt_rand(0, 1) === 1 ? '#' : '?';
});

return static::lexify(static::numerify($string));
Expand Down

0 comments on commit 7a06315

Please sign in to comment.