PortableInfobox/services/Helpers/InfoboParamsValidator.php

31 lines
660 B
PHP
Raw Normal View History

2015-06-11 09:47:22 +00:00
<?php
namespace Wikia\PortableInfobox\Helpers;
class InfoboParamsValidator {
private $supportedParams = [
'theme',
'theme-source',
'layout'
];
/**
* validates infobox tags attribute names
* @param array $params
* @throws InvalidInfoboxParamsException
* @todo: consider using hashmap instead of array ones validator grows
2015-06-11 10:54:10 +00:00
* @returns boolean
2015-06-11 09:47:22 +00:00
*/
public function validateParams( $params ) {
foreach ( array_keys( $params ) as $param ) {
2015-06-11 10:54:10 +00:00
if ( !in_array( $param, $this->supportedParams ) ) {
2015-06-11 09:47:22 +00:00
throw new InvalidInfoboxParamsException( $param );
}
}
2015-06-11 10:54:10 +00:00
return true;
2015-06-11 09:47:22 +00:00
}
}
class InvalidInfoboxParamsException extends \Exception {
}