Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
ParserStatus
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getException
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getWarnings
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCondsUsed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isValid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\AbuseFilter\Parser;
4
5use MediaWiki\Extension\AbuseFilter\Parser\Exception\ExceptionBase;
6use MediaWiki\Extension\AbuseFilter\Parser\Exception\UserVisibleWarning;
7
8class ParserStatus {
9    /** @var ExceptionBase|null */
10    protected $excep;
11    /** @var UserVisibleWarning[] */
12    protected $warnings;
13    /** @var int */
14    protected $condsUsed;
15
16    /**
17     * @param ExceptionBase|null $excep An exception thrown while parsing, or null if it parsed correctly
18     * @param UserVisibleWarning[] $warnings
19     * @param int $condsUsed
20     */
21    public function __construct(
22        ?ExceptionBase $excep,
23        array $warnings,
24        int $condsUsed
25    ) {
26        $this->excep = $excep;
27        $this->warnings = $warnings;
28        $this->condsUsed = $condsUsed;
29    }
30
31    /**
32     * @return ExceptionBase|null
33     */
34    public function getException(): ?ExceptionBase {
35        return $this->excep;
36    }
37
38    /**
39     * @return UserVisibleWarning[]
40     */
41    public function getWarnings(): array {
42        return $this->warnings;
43    }
44
45    /**
46     * @return int
47     */
48    public function getCondsUsed(): int {
49        return $this->condsUsed;
50    }
51
52    /**
53     * Whether the parsing/evaluation happened successfully.
54     * @return bool
55     */
56    public function isValid(): bool {
57        return !$this->excep;
58    }
59}