Page MenuHomeWickedGov Phorge

LimitBatchResult.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

LimitBatchResult.php

<?php
namespace Wikimedia\WRStats;
/**
* A class representing the results from a batch operation.
*
* @since 1.39
*/
class LimitBatchResult {
/** @var LimitOperationResult[] */
private $results;
/** @var bool|null */
private $allowed;
/**
* @internal Use WRStatsFactory::createRateLimiter() instead
* @param LimitOperationResult[] $results
*/
public function __construct( $results ) {
$this->results = $results;
}
/**
* Determine whether the batch as a whole is/was allowed
*
* @return bool
*/
public function isAllowed() {
if ( $this->allowed === null ) {
$this->allowed = true;
foreach ( $this->results as $result ) {
if ( !$result->isAllowed() ) {
$this->allowed = false;
break;
}
}
}
return $this->allowed;
}
/**
* Get LimitOperationResult objects for operations exceeding the limit.
*
* The keys will match the input array. For input arrays constructed by
* LimitBatch, the keys will be the condition names.
*
* @return LimitOperationResult[]
*/
public function getFailedResults() {
$failed = [];
foreach ( $this->results as $i => $result ) {
if ( !$result->isAllowed() ) {
$failed[$i] = $result;
}
}
return $failed;
}
/**
* Get LimitOperationResult objects for operations not exceeding the limit.
*
* The keys will match the input array. For input arrays constructed by
* LimitBatch, the keys will be the condition names.
*
* @return LimitOperationResult[]
*/
public function getPassedResults() {
$passed = [];
foreach ( $this->results as $i => $result ) {
if ( $result->isAllowed() ) {
$passed[$i] = $result;
}
}
return $passed;
}
/**
* Get LimitOperationResult objects for all operations in the batch.
*
* The keys will match the input array. For input arrays constructed by
* LimitBatch, the keys will be the condition names.
*
* @return LimitOperationResult[]
*/
public function getAllResults() {
return $this->results;
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, May 16, 12:38 (1 d, 4 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4b/9c/d6704ea97b242e7c0f8c28186109
Default Alt Text
LimitBatchResult.php (1 KB)

Event Timeline