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

Move TCNo and INN from calculator to localized providers #108

Merged
merged 35 commits into from
Dec 21, 2020

Conversation

krsriq
Copy link

@krsriq krsriq commented Dec 5, 2020

What is the reason for this PR?

Inn.php verifies the Russian tax identification number (INN number), TCNo.php the Turkish Identity Number, but both are currently placed in the core Calculator.

Author's checklist

Summary of changes

  • Moved Calculator\Inn methods to Provider\ru_RU\Company, Calculator\TCNo methods to Provider\tr_TR\Person
  • Marked Inn and TcNo classes and methods deprecated
  • Called the new Company/Person methods from Inn and TcNo for BC
  • Moved the test methods from Calculator to their respective Company and Person test classes

Review checklist

  • All checks have passed
  • Changes are approved by maintainer

@krsriq krsriq changed the title move tcno and inn from calculator to localized providers Move TCNo and INN from calculator to localized providers Dec 5, 2020
@pimjansen pimjansen added the enhancement New feature or request label Dec 5, 2020
src/Faker/Calculator/Inn.php Outdated Show resolved Hide resolved
}

/**
* Checks whether a TCNo has a valid checksum
*
* @deprecated Use {@link \Faker\Provider\tr_TR\Person::tcNoIsValid()} instead
Copy link
Member

Choose a reason for hiding this comment

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

Please be consistent in where you place the @deprecated (after @return)

Copy link
Author

Choose a reason for hiding this comment

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

Looks better now, thanks.

krsriq and others added 3 commits December 6, 2020 15:16
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
src/Faker/Calculator/Inn.php Outdated Show resolved Hide resolved
src/Faker/Calculator/Inn.php Outdated Show resolved Hide resolved
src/Faker/Calculator/TCNo.php Outdated Show resolved Hide resolved
src/Faker/Calculator/TCNo.php Outdated Show resolved Hide resolved
src/Faker/Calculator/TCNo.php Outdated Show resolved Hide resolved
krsriq and others added 5 commits December 6, 2020 17:36
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Copy link
Member

@bram-pkg bram-pkg left a comment

Choose a reason for hiding this comment

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

One small change requested, otherwise it looks good!

src/Faker/Provider/ru_RU/Company.php Outdated Show resolved Hide resolved
src/Faker/Provider/ru_RU/Company.php Outdated Show resolved Hide resolved
src/Faker/Provider/ru_RU/Company.php Outdated Show resolved Hide resolved
src/Faker/Provider/ru_RU/Company.php Outdated Show resolved Hide resolved
src/Faker/Provider/ru_RU/Company.php Outdated Show resolved Hide resolved
src/Faker/Provider/ru_RU/Company.php Outdated Show resolved Hide resolved
src/Faker/Provider/tr_TR/Person.php Outdated Show resolved Hide resolved
krsriq and others added 4 commits December 6, 2020 22:17
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
@bram-pkg
Copy link
Member

bram-pkg commented Dec 6, 2020

Let's enable single_quotes and then rebase.

@krsriq
Copy link
Author

krsriq commented Dec 8, 2020

Let's enable single_quotes and then rebase.

@bramceulemans - rebased a while ago.

src/Faker/Calculator/Inn.php Outdated Show resolved Hide resolved
@bram-pkg
Copy link
Member

Looks good to me now.
/cc @GrahamCampbell

test/Faker/Provider/tr_TR/PersonTest.php Outdated Show resolved Hide resolved
test/Faker/Provider/tr_TR/PersonTest.php Outdated Show resolved Hide resolved

/**
* @dataProvider tcNoChecksumProvider
* @param $tcNo
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Author

Choose a reason for hiding this comment

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

Added param type now.

test/Faker/Provider/tr_TR/PersonTest.php Outdated Show resolved Hide resolved
Signed-off-by: Daniel Schmelz <daniel@schmelz.org>
@krsriq krsriq mentioned this pull request Dec 14, 2020
3 tasks
@krsriq
Copy link
Author

krsriq commented Dec 14, 2020

@GrahamCampbell added @dataProvider @param types here now (and fixed them in the other class that was missing this with #147).

}

return (string) (($sum % 11) % 10);
return \Faker\Provider\ru_RU\Company::inn10Checksum($inn);

Choose a reason for hiding this comment

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

Im not happy with this where we have a generic method call a locale specific?

*/
public static function isValid($inn)
{
return strlen($inn) === 10 && self::checksum($inn) === $inn[9];
return \Faker\Provider\ru_RU\Company::inn10IsValid($inn);

Choose a reason for hiding this comment

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

Same here

Copy link
Author

Choose a reason for hiding this comment

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

@pimjansen the problem here is that INN and TCNo are locale specific but somehow ended up in the base Calculator.

We keep them in Calculator (and call the locale specific providers) and mark them deprecated for BC , but they should be removed from the Calculator asap IMO - especially considering Faker 2.0, where it makes no sense to have this in the core.

$eleventhDigit = ($evenSum + $oddSum + $tenthDigit) % 10;

return $tenthDigit . $eleventhDigit;
return \Faker\Provider\tr_TR\Person::tcNoChecksum($identityPrefix);

Choose a reason for hiding this comment

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

Same here

*/
public static function isValid($tcNo)
{
return self::checksum(substr($tcNo, 0, -2)) === substr($tcNo, -2, 2);
return \Faker\Provider\tr_TR\Person::tcNoIsValid($tcNo);

Choose a reason for hiding this comment

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

Same

# Conflicts:
#	src/Faker/Calculator/Inn.php
#	src/Faker/Calculator/TCNo.php
#	src/Faker/Provider/ru_RU/Company.php
#	test/Faker/Calculator/InnTest.php
#	test/Faker/Calculator/TCNoTest.php
@pimjansen
Copy link

@krsriq lgtm after a green build

@krsriq
Copy link
Author

krsriq commented Dec 21, 2020

@pimjansen done!

@pimjansen pimjansen merged commit 830891d into FakerPHP:main Dec 21, 2020
krsriq added a commit to krsriq/Faker that referenced this pull request Jan 7, 2021
* move tcno and inn from calculator to localized providers

* change inn method name

* cleanup

* Update src/Faker/Calculator/Inn.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* cleanup

* fix bc change

* Update src/Faker/Calculator/Inn.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Calculator/TCNo.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Calculator/Inn.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Calculator/TCNo.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Calculator/TCNo.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Provider/ru_RU/Company.php

* Update src/Faker/Provider/ru_RU/Company.php

* Update src/Faker/Provider/ru_RU/Company.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Provider/ru_RU/Company.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Provider/tr_TR/Person.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Provider/ru_RU/Company.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Update src/Faker/Provider/ru_RU/Company.php

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>

* Improve consistency of comments and phpdoc (FakerPHP#110)

* Improve consistency of comments and phpdoc

* Add StyleCI changes

* Enable whitespace_after_comma_in_array fixer (FakerPHP#112)

* Enable whitespace_after_comma_in_array fixer

* Apply fixes from StyleCI

* Minor cleanup (FakerPHP#113)

* enable StyleCI single_quote (FakerPHP#116)

* Apply fixes from StyleCI

* Enable modernize_types_casting fixer (FakerPHP#117)

* Enable modernize_types_casting fixer

* Apply fixes from StyleCI

* move tcno and inn from calculator to localized providers

* fix bc change

* fix merge issue

* fix newline

* re-add docblock empty line

* add type to data provider params

Signed-off-by: Daniel Schmelz <daniel@schmelz.org>

* run make cs

* run make cs

Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
Co-authored-by: Graham Campbell <GrahamCampbell@users.noreply.github.com>
@krsriq krsriq deleted the move_tcno_and_inn branch January 23, 2022 18:27
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.

Move Russian Inn and Turkish TCNo from Calculator to localized providers
4 participants