
Daniel Mulder - 2014-12-06 19:12:08
Hi,
Great work on this class. Very useful. Although I'm not a programmer by trade but I am working on an app for myself. The classes I made are developing some nicely and getting better every time. I use filter_var with the _set and _get method like this:
public function __set($Property, $Value)
{
if ($Property == 'Username') {
$this->username = filter_var($Value, FILTER_SANITIZE_MAGIC_QUOTES);
}
if ($Property == 'Password') {
$this->username = filter_var($Value, FILTER_SANITIZE_MAGIC_QUOTES);
}
if ($Property == 'User_id') {
$this->user_id = filter_var($Value, FILTER_SANITIZE_NUMBER_INT);
}
}
I am thinking of incorporating this as replacement for the string functions. This should make it compacter and more reliable? Or am I not seeing the big picture?
Also thinking about adding a inaccessible method to set the hashed password property as magic _set _get method. Would be nice to have something like this as an inaccessible magic property:
_set($Password) {
if( !isset( $this->cost ))
{
$cost = 10;
do {
$cost++;
$start = microtime(true);
password_hash("testhestring", PASSWORD_BCRYPT, ["cost" => $cost]);
$end = microtime(true);
} while (($end - $start) < $timeTarget);
$this->hash_base_rate = $cost
}
else { password_hash( "testhestring",
PASSWORD_BCRYPT,
["cost" => $this->hash_base_rate]);
}
}
Or is this silly of me?
Thanks and cheers!