codice-fiscale icon indicating copy to clipboard operation
codice-fiscale copied to clipboard

Public Functions?

Open felsspat opened this issue 7 years ago • 5 comments

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.

felsspat avatar May 08 '17 14:05 felsspat

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

DavidePastore avatar May 13 '17 14:05 DavidePastore

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;
}

felsspat avatar May 15 '17 11:05 felsspat

This is related to #10.

DavidePastore avatar May 26 '19 17:05 DavidePastore

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?

gadiener avatar May 27 '19 08:05 gadiener

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?

ManuDoni avatar Feb 09 '22 15:02 ManuDoni