Update JWTEncoder.php

check for algorithm before validating so $jws->isvalid() can be called with a correct key