PortableInfobox/services/Helpers/InfoboxParamsValidator.php
2016-12-27 12:10:11 +01:00

32 lines
687 B
PHP

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