Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
LimitOperationResult
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
3 / 3
3
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
 isAllowed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 dump
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Wikimedia\WRStats;
4
5/**
6 * Information about the result of a single item in a limit batch
7 *
8 * @since 1.39
9 */
10class LimitOperationResult {
11    /** @var LimitCondition */
12    public $condition;
13
14    /** @var int The previous metric value before the current action was executed */
15    public $prevTotal;
16
17    /** @var int The value the metric would have if the increment operation were allowed */
18    public $newTotal;
19
20    /**
21     * @internal
22     *
23     * @param LimitCondition $condition
24     * @param int $prevTotal
25     * @param int $newTotal
26     */
27    public function __construct( LimitCondition $condition, $prevTotal, $newTotal ) {
28        $this->condition = $condition;
29        $this->prevTotal = $prevTotal;
30        $this->newTotal = $newTotal;
31    }
32
33    /**
34     * Whether the operation was/is allowed.
35     *
36     * @return bool
37     */
38    public function isAllowed() {
39        return $this->newTotal <= $this->condition->limit;
40    }
41
42    /**
43     * Get a string representing the object, for testing or debugging
44     *
45     * @return string
46     */
47    public function dump() {
48        return "LimitActionResult{{$this->newTotal}/{$this->condition->limit}}";
49    }
50}