supportedParams ) ) { throw new InvalidInfoboxParamsException( $param ); } } return true; } /** * validates if argument is valid color value. Currently only hex values are supported * @param $color * @return bool * @throws InvalidColorValueException */ public function validateColorValue( $color ) { if ( preg_match('/^(#?[a-f0-9]{3}([a-f0-9]{3})?)$/i', $color) ) { return true; } throw new InvalidColorValueException(); } /** * checks if given layout name is supported * @param $layoutName * @return bool */ public function validateLayout( $layoutName ) { return $layoutName && in_array( $layoutName, $this->supportedLayouts ); } } class InvalidInfoboxParamsException extends \Exception { } class InvalidColorValueException extends \Exception { }