public function check(OODBBean $bean)
{
//Is all meta information present?
if (!isset($bean->id)) {
throw new RedException('Bean has incomplete Meta Information id ');
}
if (!$bean->getMeta('type')) {
throw new RedException('Bean has incomplete Meta Information II');
}
//Pattern of allowed characters
$pattern = '/[^a-z0-9_]/i';
//Does the type contain invalid characters?
if (preg_match($pattern, $bean->getMeta('type'))) {
throw new RedException('Bean Type is invalid');
}
//Are the properties and values valid?
foreach ($bean as $prop => $value) {
if (is_array($value) || is_object($value)) {
throw new RedException("Invalid Bean value: property {$prop}");
} else {
if (strlen($prop) < 1 || preg_match($pattern, $prop)) {
throw new RedException("Invalid Bean property: property {$prop}");
}
}
}
}