2011-05-28 00:52:26 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-14 00:21:04 +01:00
|
|
|
final class HeraldRepetitionPolicyConfig {
|
2011-05-28 00:52:26 +02:00
|
|
|
const FIRST = 'first'; // only execute the first time (no repeating)
|
|
|
|
const EVERY = 'every'; // repeat every time
|
|
|
|
|
|
|
|
private static $policyIntMap = array(
|
|
|
|
self::FIRST => 0,
|
|
|
|
self::EVERY => 1,
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $policyMap = array(
|
|
|
|
self::FIRST => 'only the first time',
|
|
|
|
self::EVERY => 'every time',
|
|
|
|
);
|
|
|
|
|
|
|
|
public static function getMap() {
|
|
|
|
return self::$policyMap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getMapForContentType($type) {
|
|
|
|
switch ($type) {
|
|
|
|
case HeraldContentTypeConfig::CONTENT_TYPE_DIFFERENTIAL:
|
|
|
|
return array_select_keys(
|
|
|
|
self::$policyMap,
|
|
|
|
array(
|
|
|
|
self::EVERY,
|
|
|
|
self::FIRST,
|
|
|
|
));
|
|
|
|
|
|
|
|
case HeraldContentTypeConfig::CONTENT_TYPE_COMMIT:
|
|
|
|
return array();
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw new Exception("Unknown content type '{$type}'.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function toInt($str) {
|
|
|
|
return idx(self::$policyIntMap, $str, self::$policyIntMap[self::EVERY]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function toString($int) {
|
|
|
|
return idx(array_flip(self::$policyIntMap), $int, self::EVERY);
|
|
|
|
}
|
|
|
|
}
|