DavidePastore / codice-fiscale

A PHP library to calculate and check the italian tax code (codice fiscale).
GNU General Public License v2.0
100 stars 19 forks source link

Public Functions? #9

Open felsspat opened 7 years ago

felsspat commented 7 years ago

Hi,

could you please make the functions like calculateSurname() and calculateName() public? The reason is we don't have the belfioreCode or birthday of our Italian customers, but we want to check the rest of the code.

DavidePastore commented 7 years ago

Hi @felsspat , this could be a solution but I'd like to have all in this library because I think it's a responsability of it. What I'd prefer is to have a PartialChecker and a PartialCalculator that extends the main Checker and Calculator, to only check/calculate partials of codice fiscale. What do you think of it? /cc @gadiener

felsspat commented 7 years ago

Hi @gadiener, thanks for answering!

That would be great too. Since we don't have the place of birth and the birthday of our customers all I'm doing now is a check of the name and the checksum.

$calculator = new Calculator($person);
$nameString = $calculator->calculateSurname() . $calculator->calculateName();

if (substr($taxId, 0, 6) !== $nameString) {
    return false;
}

if ($calculator->calculateCheckDigit(substr($taxId, 0 ,15)) !== $taxId[15]) {
    return false;
}
DavidePastore commented 5 years ago

This is related to #10.

gadiener commented 5 years ago

Hi @DavidePastore,

yes, I agree with you. Separating responsibilities by extending the main classes seems to me to be the right approach. I think this should be done in the application domain and not in the library. However we should modify the visibility of those methods to allow their use in subclasses.

What do you think?

ManuDoni commented 2 years ago

Hello @DavidePastore, I would like to make partial checks as well, can I send a PR making those methods (calculateSurname, calculateName, calculateBirthDateAndGender) at least protected so we can extend the Calculator class?