| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\WRStats; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class LimitBatchResult { |
| 11 |
|
| 12 |
private $results; |
| 13 |
|
| 14 |
|
| 15 |
private $allowed; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public function __construct( $results ) { |
| 22 |
$this->results = $results; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function isAllowed() { |
| 31 |
if ( $this->allowed === null ) { |
| 32 |
$this->allowed = true; |
| 33 |
foreach ( $this->results as $result ) { |
| 34 |
if ( !$result->isAllowed() ) { |
| 35 |
$this->allowed = false; |
| 36 |
break; |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
return $this->allowed; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function getFailedResults() { |
| 52 |
$failed = []; |
| 53 |
foreach ( $this->results as $i => $result ) { |
| 54 |
if ( !$result->isAllowed() ) { |
| 55 |
$failed[$i] = $result; |
| 56 |
} |
| 57 |
} |
| 58 |
return $failed; |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public function getPassedResults() { |
| 70 |
$passed = []; |
| 71 |
foreach ( $this->results as $i => $result ) { |
| 72 |
if ( $result->isAllowed() ) { |
| 73 |
$passed[$i] = $result; |
| 74 |
} |
| 75 |
} |
| 76 |
return $passed; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
public function getAllResults() { |
| 88 |
return $this->results; |
| 89 |
} |
| 90 |
} |