Created
February 1, 2013 15:10
-
-
Save damiankloip/4691859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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