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

Added medical extension to core #232

Merged
merged 1 commit into from
Dec 30, 2020

Conversation

pimjansen
Copy link

@pimjansen pimjansen commented Dec 22, 2020

What is the reason for this PR?

Medical added as Core Extension

  • A new feature
  • Fixed an issue (resolve #ID)

Author's checklist

Summary of changes

Medical added as Core Extension

Review checklist

  • All checks have passed
  • Changes are approved by maintainer

@pimjansen pimjansen added the enhancement New feature or request label Dec 22, 2020
@Nyholm
Copy link
Member

Nyholm commented Dec 22, 2020

This would be a good example of a super standard extension.

@pimjansen
Copy link
Author

This would be a good example of a super standard extension.

Tbh i don't see added value in adding extensions for everything. Since the fact that this is not language specific and generic we could just leave it in Core?

Size wise it is not an issue where the only real problems there are with the actual realText methods

@Nyholm
Copy link
Member

Nyholm commented Dec 22, 2020

Tbh i don't see added value in adding extensions for everything. Since the fact that this is not language specific and generic we could just leave it in Core?

Just a terminology check. The Faker\Core\Medical is an "extension". Is it also a "Core extension". I agree with you that the German package will not have a class that implements Faker\Extension\MedicalExtension. But that is fine.


We need to add an extension interface to everything that has a "helper method" in Generator.

Comment on lines 24 to 26
/**
* @inheritDoc
*/
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
* @inheritDoc
*/

Can we remove this?

This information is automatically inherited, and these DocBlocks are generally useless.

{
public function testBloodType(): void
{
self::assertContains($this->faker->bloodType(), ['A', 'AB', 'B', 'O']);
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a more appropriate assertion?

As far as I am concerned, when using assertContains(), then $needle would be the expected value here, whereas $haystack is the actual value.

Right now it is the other way around.

Copy link
Author

Choose a reason for hiding this comment

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

The needle is always the value and the haystack the expected? In this case needle also needs to be a string.

This is a 1:1 copy from the existing tests so i wonder where you want to?

/**
* @experimental This class is experimental and does not fall under our BC promise
*/
final class Medical implements Extension\MedicalExtension
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a Blood extension would make more sense?

All of the methods in this class share the blood prefix.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that would make more sense.

Copy link
Author

Choose a reason for hiding this comment

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

Renamed and reword to Blood instead

@pimjansen
Copy link
Author

Understand what you mean @Nyholm. What approach will we take here since i do not really see value in splitting the not language specific things as well. Or will we put the code in Faker\Extension\Medical itself

@krsriq
Copy link

krsriq commented Dec 22, 2020

@pimjansen - I think it's fine to use a Faker\Extension interface for every extension.
Who knows, it might be that blood types in fact need to be localized in some circumstances - for example some countries seem to use 0 instead of O, as was mentioned in #61.

@Nyholm
Copy link
Member

Nyholm commented Dec 22, 2020

What approach will we take here since i do not really see value in splitting the not language specific things as well.

I argue that we dont need to add this extension to a language specific package.

Or will we put the code in Faker\Extension\Medical itself

No, never, we must use an interface because we define methods in Generator

@@ -62,6 +62,7 @@ public static function defaultExtensions(): array
{
return [
FileExtension::class => Core\File::class,
MedicalExtension::class => Core\Medical::class,
Copy link
Member

Choose a reason for hiding this comment

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

When you rename this to BloodExtension, then make sure this is in alphabetical order. It would please my OCD =)

Copy link
Member

Choose a reason for hiding this comment

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

How about Medical\BloodExtension?

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the list of the current features we have, there is nothing else that would fit in Medical namespace.

Copy link
Member

Choose a reason for hiding this comment

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

We could add a list of deceases, but that would be localized.

Copy link
Member

Choose a reason for hiding this comment

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

I would rather keep the list of features as small as possible.

I am more than happy to add all kinds of medical related stuff in a separate package. Ie fakerphp/medical.

Lets focus on the current features and this PR at the moment and later we can discuss if this belongs to core or not

Copy link
Member

Choose a reason for hiding this comment

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

I would like to keep this in a fakerphp/medical, this doesn’t feel like something that every application would need. Which is kind of the point of our “core”, to keep general and commonly needed extensions.

Copy link
Author

Choose a reason for hiding this comment

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

I doubt that last one a bit since it brings the ease of use. Nobody wants to have 6 extra dependencies for a package like this.

I ofc agree to split of all the language specifics where it is impossible to maintain centralised and also all the language packs holds a lot of storage but for all other generic stuff?

Since for example when i need to create a dummy person with all its info i need a for example Swedish pack, Faker core and a medical extension to add its blood type

@Nyholm
Copy link
Member

Nyholm commented Dec 26, 2020

Pim, could you please rename this extension to Blood?

@@ -62,6 +62,7 @@ public static function defaultExtensions(): array
{
return [
FileExtension::class => Core\File::class,
MedicalExtension::class => Core\Medical::class,
Copy link
Member

Choose a reason for hiding this comment

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

I would like to keep this in a fakerphp/medical, this doesn’t feel like something that every application would need. Which is kind of the point of our “core”, to keep general and commonly needed extensions.

@pimjansen
Copy link
Author

Pim, could you please rename this extension to Blood?

Yeah will update and include all the comments somewhere this week

@pimjansen pimjansen force-pushed the feature/medical-core-extension branch from 862cbed to 8f1badd Compare December 27, 2020 13:55
Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you. I am happy with this PR.

@pimjansen pimjansen merged commit 8645d0c into FakerPHP:main Dec 30, 2020
@pimjansen pimjansen deleted the feature/medical-core-extension branch December 30, 2020 16:50
@Nyholm Nyholm mentioned this pull request Jan 7, 2021
@krsriq krsriq mentioned this pull request Jan 7, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants