- private $types = array(
- '' => array( 'type' => '', 'class' => 'InvalidPassword' ),
- );
+ private $types = [
+ '' => [ 'type' => '', 'class' => InvalidPassword::class ],
+ ];
+
+ /**
+ * Construct a new password factory.
+ * Most of the time you'll want to use MediaWikiServices::getPasswordFactory instead.
+ * @param array $config Mapping of password type => config
+ * @param string $default Default password type
+ * @see PasswordFactory::register
+ * @see PasswordFactory::setDefaultType
+ */
+ public function __construct( array $config = [], $default = '' ) {
+ foreach ( $config as $type => $options ) {
+ $this->register( $type, $options );
+ }
+
+ if ( $default !== '' ) {
+ $this->setDefaultType( $default );
+ }
+ }