-
Notifications
You must be signed in to change notification settings - Fork 348
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
Conversation
src/Faker/Calculator/TCNo.php
Outdated
} | ||
|
||
/** | ||
* Checks whether a TCNo has a valid checksum | ||
* | ||
* @deprecated Use {@link \Faker\Provider\tr_TR\Person::tcNoIsValid()} instead |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better now, thanks.
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>
Co-authored-by: Bram Ceulemans <bramceulemans@me.com>
There was a problem hiding this 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!
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>
Let's enable |
* Improve consistency of comments and phpdoc * Add StyleCI changes
* Enable whitespace_after_comma_in_array fixer * Apply fixes from StyleCI
* Enable modernize_types_casting fixer * Apply fixes from StyleCI
@bramceulemans - rebased a while ago. |
Looks good to me now. |
|
||
/** | ||
* @dataProvider tcNoChecksumProvider | ||
* @param $tcNo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added param type now.
Signed-off-by: Daniel Schmelz <daniel@schmelz.org>
@GrahamCampbell added |
} | ||
|
||
return (string) (($sum % 11) % 10); | ||
return \Faker\Provider\ru_RU\Company::inn10Checksum($inn); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
@krsriq lgtm after a green build |
@pimjansen done! |
* 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>
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 coreCalculator
.Author's checklist
Summary of changes
Calculator\Inn
methods toProvider\ru_RU\Company
,Calculator\TCNo
methods toProvider\tr_TR\Person
Inn
andTcNo
classes and methods deprecatedCompany
/Person
methods fromInn
andTcNo
for BCCalculator
to their respectiveCompany
andPerson
test classesReview checklist