Skip to content

Instantly share code, notes, and snippets.

@damiankloip
Created February 1, 2013 15:10
Show Gist options
  • Save damiankloip/4691859 to your computer and use it in GitHub Desktop.
Save damiankloip/4691859 to your computer and use it in GitHub Desktop.
<?php
protected function supportedInterfaceOrClass($data, $format = NULL) {
// If there is a format passed in and specified on the class, check if it is
// correct.
if (isset($format) && isset($this->format) && !in_array($format, $this->format)) {
return FALSE;
}
if (is_object($data)) {
foreach ((array) $this->supportedInterfaceOrClass as $name) {
if ($data instanceof $name) {
return TRUE;
}
}
}
else {
$reflection = new ReflectionClass($type);
foreach ((array) $this->supportedInterfaceOrClass as $name) {
if ($reflection->implementsInterface($this->supportedInterfaceOrClass)) {
return TRUE;
}
}
}
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment