mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-16 12:35:31 +00:00
31 lines
660 B
PHP
31 lines
660 B
PHP
<?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
|
|
* @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 {
|
|
}
|