interchange = $interchange; foreach ($interchange->namespaces as $namespace) { $this->validateNamespace($namespace); } foreach ($interchange->directives as $directive) { $this->validateDirective($directive); } } public function validateNamespace($n) { $this->context = "namespace '{$n->namespace}'"; $this->with($n, 'namespace') ->assertIsString() ->assertNotEmpty() ->assertAlnum(); $this->with($n, 'description') ->assertIsString() ->assertNotEmpty(); } public function validateDirective($d) { $this->context = "directive '{$d->id}'"; } // protected helper functions protected function with($obj, $member) { return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->interchange, $this->context, $obj, $member); } }