Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/parametertype/ConduitEpochParameterType.php
- This file was copied to src/applications/conduit/parametertype/ConduitBoolParameterType.php, src/applications/conduit/parametertype/ConduitIntParameterType.php, src/applications/conduit/parametertype/ConduitStringParameterType.php.
<?php | <?php | ||||
final class ConduitEpochParameterType | final class ConduitEpochParameterType | ||||
extends ConduitListParameterType { | extends ConduitListParameterType { | ||||
protected function getParameterValue(array $request, $key) { | protected function getParameterValue(array $request, $key) { | ||||
$value = parent::getParameterValue($request, $key); | $value = parent::getParameterValue($request, $key); | ||||
if (!is_int($value)) { | if (!is_int($value)) { | ||||
$this->raiseValidationException( | $this->raiseValidationException( | ||||
$request, | $request, | ||||
$key, | $key, | ||||
pht('Expected integer, got something else.')); | pht('Expected epoch timestamp as integer, got something else.')); | ||||
} | |||||
if ($value <= 0) { | |||||
$this->raiseValidationException( | |||||
$request, | |||||
$key, | |||||
pht('Epoch timestamp must be larger than 0, got %d.', $value)); | |||||
} | } | ||||
return $value; | return $value; | ||||
} | } | ||||
protected function getParameterTypeName() { | protected function getParameterTypeName() { | ||||
return 'epoch'; | return 'epoch'; | ||||
} | } | ||||
protected function getParameterFormatDescriptions() { | protected function getParameterFormatDescriptions() { | ||||
return array( | return array( | ||||
pht('Epoch timestamp, as an integer.'), | pht('Epoch timestamp, as an integer.'), | ||||
); | ); | ||||
} | } | ||||
protected function getParameterExamples() { | protected function getParameterExamples() { | ||||
return array( | return array( | ||||
'["PHID-PROJ-1111"]', | '1450019509', | ||||
'["backend"]', | |||||
'["PHID-PROJ-2222", "frontend"]', | |||||
); | ); | ||||
} | } | ||||
} | } |