for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Mediawiki\Api;
use InvalidArgumentException;
/**
* @since 0.1
*
* @author Addshore
* @author RobinR1
* @author Bene
* Represents a user that can log in to the api
*/
class ApiUser {
* @var string
private $password;
private $username;
private $domain;
* @param string $username The username.
* @param string $password The user's password.
* @param string|null $domain The domain (for authentication systems that support domains).
* @throws \InvalidArgumentException
public function __construct( $username, $password, $domain = null ) {
$domainIsStringOrNull = ( is_string( $domain ) || $domain === null );
if ( !is_string( $username ) || !is_string( $password ) || !$domainIsStringOrNull ) {
throw new InvalidArgumentException( 'Username, Password and Domain must all be strings' );
}
if ( empty( $username ) || empty( $password ) ) {
throw new InvalidArgumentException( 'Username and Password are not allowed to be empty' );
$this->username = $username;
$this->password = $password;
$this->domain = $domain;
* @return string
public function getUsername() {
return $this->username;
public function getPassword() {
return $this->password;
public function getDomain() {
return $this->domain;
* @param mixed $other Another ApiUser object to compare with.
* @return bool
public function equals( $other ) {
return $other instanceof self
&& $this->username == $other->getUsername()
&& $this->password == $other->getPassword()
&& $this->domain == $other->getDomain();