public function __construct($type = self::TYPE_BASIC, $realmOrParams = 'api', array $params = [])
{
$this->type = in_array($type, [self::TYPE_BASIC, self::TYPE_DIGEST, self::TYPE_OAUTH2]) ? $type : self::TYPE_BASIC;
if ($type === self::TYPE_OAUTH2 && is_array($realmOrParams)) {
$this->exchangeArray($realmOrParams);
} else {
$this->realm = $realmOrParams;
$this->exchangeArray($params);
}
}