2013-07-10 22:45:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialReviewerStatus {
|
|
|
|
|
2013-10-07 02:09:24 +02:00
|
|
|
const STATUS_BLOCKING = 'blocking';
|
2013-07-10 22:45:14 +02:00
|
|
|
const STATUS_ADDED = 'added';
|
2013-10-05 03:58:35 +02:00
|
|
|
const STATUS_ACCEPTED = 'accepted';
|
2013-07-10 22:45:14 +02:00
|
|
|
const STATUS_REJECTED = 'rejected';
|
2013-10-05 03:58:35 +02:00
|
|
|
const STATUS_COMMENTED = 'commented';
|
2014-03-05 19:47:29 +01:00
|
|
|
const STATUS_ACCEPTED_OLDER = 'accepted-older';
|
|
|
|
const STATUS_REJECTED_OLDER = 'rejected-older';
|
2013-07-10 22:45:14 +02:00
|
|
|
|
2014-02-25 21:37:11 +01:00
|
|
|
/**
|
|
|
|
* Returns the relative strength of a status, used to pick a winner when a
|
|
|
|
* transaction group makes several status changes to a particular reviewer.
|
|
|
|
*
|
|
|
|
* For example, if you accept a revision and leave a comment, the transactions
|
|
|
|
* will attempt to update you to both "commented" and "accepted". We want
|
|
|
|
* "accepted" to win, because it's the stronger of the two.
|
|
|
|
*
|
|
|
|
* @param const Reviewer status constant.
|
|
|
|
* @return int Relative strength (higher is stronger).
|
|
|
|
*/
|
|
|
|
public static function getStatusStrength($constant) {
|
|
|
|
$map = array(
|
|
|
|
self::STATUS_ADDED => 1,
|
|
|
|
|
|
|
|
self::STATUS_COMMENTED => 2,
|
|
|
|
|
|
|
|
self::STATUS_BLOCKING => 3,
|
|
|
|
|
2014-03-05 19:47:29 +01:00
|
|
|
self::STATUS_ACCEPTED_OLDER => 4,
|
|
|
|
self::STATUS_REJECTED_OLDER => 4,
|
|
|
|
|
|
|
|
self::STATUS_ACCEPTED => 5,
|
|
|
|
self::STATUS_REJECTED => 5,
|
2014-02-25 21:37:11 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return idx($map, $constant, 0);
|
|
|
|
}
|
|
|
|
|
2013-07-10 22:45:14 +02:00
|
|
|
}
|