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

Singleton class for SSN #12

Closed
soullivaneuh opened this issue Apr 21, 2015 · 6 comments
Closed

Singleton class for SSN #12

soullivaneuh opened this issue Apr 21, 2015 · 6 comments

Comments

@soullivaneuh
Copy link
Contributor

The SSN validator is special. We have to instantiate it before use it for validation.

I think is for avoid code generation (generate('CA')) on each validation?

In this case, could we think about use it as a singleton class?

See here (FR): http://fr.wikipedia.org/wiki/Singleton_%28patron_de_conception%29#PHP_5

I suggest it because with this code design, I will have to instantiate it on each validation with my Symfony Validator wrapping.

Could work on it. This should be on a next major release.

@ronanguilloux
Copy link
Owner

Please send a PR

@soullivaneuh
Copy link
Contributor Author

Will work on it.

Just to show you the problem:

As you can see, I have to instantiate this class for each validation.

@soullivaneuh
Copy link
Contributor Author

The generate method of Ssn is never called from class validation.

What is the goal of this method?

@ronanguilloux
Copy link
Owner

To generate a SSN, based on state.

@soullivaneuh
Copy link
Contributor Author

But it is not used for validation, is it?

If not, are you OK to make it static too?

@soullivaneuh
Copy link
Contributor Author

Closed for #34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants