Skip to content

Commit

Permalink
[Form] Add argument type checking in BaseDateTimeTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed May 10, 2011
1 parent dac798c commit 2e68801
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -32,9 +32,19 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
*
* @param string $inputTimezone The name of the input timezone
* @param string $outputTimezone The name of the output timezone
*
* @throws UnexpectedTypeException if a timezone is not a string
*/
public function __construct($inputTimezone = null, $outputTimezone = null)
{
if (!is_string($inputTimezone) && null !== $inputTimezone) {
throw new UnexpectedTypeException($inputTimezone, 'string');
}

if (!is_string($outputTimezone) && null !== $outputTimezone) {
throw new UnexpectedTypeException($outputTimezone, 'string');
}

$this->inputTimezone = $inputTimezone ?: date_default_timezone_get();
$this->outputTimezone = $outputTimezone ?: date_default_timezone_get();
}
Expand Down

0 comments on commit 2e68801

Please sign in to comment.