public function validateInterfaces()
{
$refInterface = new ReflectionClass(reset($this->advice->getInterfaces()));
$refImplementation = new ReflectionClass(reset($this->advice->getTraits()));
if (!$refInterface->isInterface()) {
throw new \InvalidArgumentException("Only interface can be introduced");
}
if (!$refImplementation->isTrait()) {
throw new \InvalidArgumentException("Only trait can be used as implementation");
}
foreach ($refInterface->getMethods() as $interfaceMethod) {
if (!$refImplementation->hasMethod($interfaceMethod->name)) {
throw new \DomainException("Implementation requires method {$interfaceMethod->name}");
}
}
}