2019-09-15 15:48:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Parser;
|
|
|
|
|
2021-08-29 22:58:17 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Parser\Exception\ExceptionBase;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleWarning;
|
|
|
|
|
2019-09-15 15:48:13 +00:00
|
|
|
class ParserStatus {
|
2021-08-29 22:58:17 +00:00
|
|
|
/** @var ExceptionBase|null */
|
2021-09-06 20:40:36 +00:00
|
|
|
protected $excep;
|
2020-12-18 16:53:36 +00:00
|
|
|
/** @var UserVisibleWarning[] */
|
2021-09-06 20:40:36 +00:00
|
|
|
protected $warnings;
|
2021-09-01 11:18:23 +00:00
|
|
|
/** @var int */
|
2021-09-06 20:40:36 +00:00
|
|
|
protected $condsUsed;
|
2019-09-15 15:48:13 +00:00
|
|
|
|
|
|
|
/**
|
2021-08-29 22:58:17 +00:00
|
|
|
* @param ExceptionBase|null $excep An exception thrown while parsing, or null if it parsed correctly
|
2020-12-18 16:53:36 +00:00
|
|
|
* @param UserVisibleWarning[] $warnings
|
2021-09-01 11:18:23 +00:00
|
|
|
* @param int $condsUsed
|
2019-09-15 15:48:13 +00:00
|
|
|
*/
|
2021-09-01 11:18:23 +00:00
|
|
|
public function __construct(
|
|
|
|
?ExceptionBase $excep,
|
|
|
|
array $warnings,
|
|
|
|
int $condsUsed
|
|
|
|
) {
|
2019-09-15 15:48:13 +00:00
|
|
|
$this->excep = $excep;
|
2020-12-18 16:53:36 +00:00
|
|
|
$this->warnings = $warnings;
|
2021-09-01 11:18:23 +00:00
|
|
|
$this->condsUsed = $condsUsed;
|
2019-09-15 15:48:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-29 22:58:17 +00:00
|
|
|
* @return ExceptionBase|null
|
2019-09-15 15:48:13 +00:00
|
|
|
*/
|
2021-08-29 22:58:17 +00:00
|
|
|
public function getException(): ?ExceptionBase {
|
2019-09-15 15:48:13 +00:00
|
|
|
return $this->excep;
|
|
|
|
}
|
2020-12-18 16:53:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return UserVisibleWarning[]
|
|
|
|
*/
|
2021-07-21 18:51:12 +00:00
|
|
|
public function getWarnings(): array {
|
2020-12-18 16:53:36 +00:00
|
|
|
return $this->warnings;
|
|
|
|
}
|
2021-02-09 11:03:24 +00:00
|
|
|
|
2021-09-01 11:18:23 +00:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getCondsUsed(): int {
|
|
|
|
return $this->condsUsed;
|
|
|
|
}
|
|
|
|
|
2021-02-09 11:03:24 +00:00
|
|
|
/**
|
2021-09-06 20:40:36 +00:00
|
|
|
* Whether the parsing/evaluation happened successfully.
|
|
|
|
* @return bool
|
2021-02-09 11:03:24 +00:00
|
|
|
*/
|
2021-09-06 20:40:36 +00:00
|
|
|
public function isValid(): bool {
|
|
|
|
return !$this->excep;
|
2021-02-09 11:03:24 +00:00
|
|
|
}
|
2019-09-15 15:48:13 +00:00
|
|
|
}
|