$this->default = $type;
}
+ /**
+ * Get the default password type
+ *
+ * @return string
+ */
+ public function getDefaultType() {
+ return $this->default;
+ }
+
/**
* Initialize the internal static variables using the global variables
*
* if a null hash is given.
*
* @param string|null $hash Existing hash or null for an invalid password
- * @return Password object
- * @throws PasswordError if hash is invalid or type is not recognized
+ * @return Password
+ * @throws PasswordError If hash is invalid or type is not recognized
*/
public function newFromCiphertext( $hash ) {
if ( $hash === null || $hash === false || $hash === '' ) {
* Make a new default password of the given type.
*
* @param string $type Existing type
- * @return Password object
- * @throws PasswordError if hash is invalid or type is not recognized
+ * @return Password
+ * @throws PasswordError If hash is invalid or type is not recognized
*/
public function newFromType( $type ) {
if ( !isset( $this->types[$type] ) ) {
* If no existing object is given, make a new default object. If one is given, clone that
* object. Then pass the plaintext to Password::crypt().
*
- * @param string $password Plaintext password
+ * @param string|null $password Plaintext password, or null for an invalid password
* @param Password|null $existing Optional existing hash to get options from
- * @return Password object
+ * @return Password
*/
public function newFromPlaintext( $password, Password $existing = null ) {
+ if ( $password === null ) {
+ return new InvalidPassword( $this, array( 'type' => '' ), null );
+ }
+
if ( $existing === null ) {
$config = $this->types[$this->default];
$obj = new $config['class']( $this, $config );