Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Add lastName gender specific on ru_RU locale #1747

Merged
merged 11 commits into from
Sep 3, 2019
Merged

Add lastName gender specific on ru_RU locale #1747

merged 11 commits into from
Sep 3, 2019

Conversation

aanfarhan
Copy link
Contributor

@aanfarhan aanfarhan commented Aug 15, 2019

Add lastName method on Person Provider ru_RU locale with gender params.

Related to #1745.

@antonkomarev
Copy link

Thank you! Just faced same issue and wanted to add a pull request.

aanfarhan and others added 3 commits August 25, 2019 21:27
Optimize code

Co-Authored-By: Andreas Möller <am@localheinz.com>
Copy link
Contributor

@localheinz localheinz left a comment

Choose a reason for hiding this comment

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

👍

@pimjansen
Copy link
Contributor

@aanfarhan @antonkomarev my russian is not so good but is this valid for all male names that they have a female equivalent with an appended "a"?
Code overall looks good so 👌🏻

{
$lastName = static::randomElement(static::$lastName);

if (static::GENDER_FEMALE === $gender) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add a link here for explanation?

For example, https://en.m.wikipedia.org/wiki/Eastern_Slavic_naming_customs#Grammar.

/cc @pimjansen

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, im not a fan of "only in our usecases" but it will do for no i guess

/**
* Return last name for the specified gender.
*
* @access public
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if using the @access annotation here is something we really need - it duplicates the public visibility keyword that is already present. Can we remove it?

Copy link
Owner

Choose a reason for hiding this comment

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

I agree, please remove it

@antonkomarev
Copy link

@pimjansen not all the female last names ends with -a, but most part or them and all the male last names presented in Faker matches this rule.

* for. If the argument is skipped a random gender will be used.
* @return string Last name
*/
public function lastName($gender = null)
Copy link
Owner

Choose a reason for hiding this comment

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

Do I understand correctly or is the generated lastName always Male by default? Shouldn't it return a random gender?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, missed that one.

@aanfarhan

Can you adjust, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll add some adjustment to the code.

@localheinz localheinz self-requested a review August 27, 2019 05:50
*/
private $faker;

public function setUp()
Copy link
Contributor

Choose a reason for hiding this comment

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

Visibility should be protected here, but we can - with the right rules - automatically fix.

return $lastName;
}

return $lastName . static::randomElement(static::$lastNameSuffix);
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about

Suggested change
return $lastName . static::randomElement(static::$lastNameSuffix);
return static::lastName(static::randomElement(array(
static::GENDER_FEMALE,
static::GENDER_MALE,
));

?

Then we can also do away with the newly introduced protected property.

@localheinz localheinz self-requested a review August 27, 2019 11:47
Copy link
Contributor

@localheinz localheinz left a comment

Choose a reason for hiding this comment

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

👍

/**
* Return last name for the specified gender.
*
* @access public
Copy link
Owner

Choose a reason for hiding this comment

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

I agree, please remove it

return $lastName;
}

return static::lastName(static::randomElement(array(
Copy link
Owner

Choose a reason for hiding this comment

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

this won't work: Person::lastName() isn't a static function. Also, I'm bot a big fan of using recursion here - I think it's overkill. Can you revert you last commit? Or perhaps you meant Person::$lastName?

@fzaninotto fzaninotto merged commit 9979692 into fzaninotto:master Sep 3, 2019
@fzaninotto
Copy link
Owner

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants