mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-12-12 16:45:21 +00:00
32 lines
687 B
PHP
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 {
|
|
}
|