aces / Loris

LORIS is a web-accessible database solution for longitudinal multi-site studies.
GNU General Public License v3.0
145 stars 173 forks source link

Make Password->validate() a static function #6449

Open johnsaigle opened 4 years ago

johnsaigle commented 4 years ago

Right now the idiom for testing password strength is doing

try {
    new Password($input);
} catch (...)

This is a bit confusing to read. Under the hood, the constructor of the class always calls its method validate() which will throw an Exception if the input is not a good password.

Creating an anonymous object like this isn't ideal. At the highest error levels phan will complain about it.

An easy fix is to change the signature of the method to be public static and update the calling code.

christinerogers commented 4 years ago

@johnsaigle is this something @laemtl (Laetitia) could tackle?

johnsaigle commented 4 years ago

I don't see why not