Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Use boolean expressions #697

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Faker/Core/Version.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading