/** * Get a hierarchy of contexts for the given class as an array * * @param string $class * @return array */ private function getContexts($class) { if ($class == Wires_Locator_Interface::GLOBAL_CONTEXT) { return array($class); } $ref = new ReflectionClass($class); $contexts = array($class); // collect interfaces if (is_array($ref->getInterfaceNames())) { foreach ($ref->getInterfaceNames() as $interface) { $contexts[] = $interface; } } // add parent class if ($ref->getParentClass()) { $parent_contexts = $this->getContexts($ref->getParentClass()->getName()); foreach ($parent_contexts as $pc) { if ($pc != Wires_Locator_Interface::GLOBAL_CONTEXT && !in_array($pc, $contexts)) { $contexts[] = $pc; } } } $contexts[] = Wires_Locator_Interface::GLOBAL_CONTEXT; return $contexts; }
public function testCheckInterfaceExtending() { $refl = new \ReflectionClass('Test\\ExtendedInterface'); $this->assertTrue($refl->isInterface()); $this->assertContains('IteratorAggregate', $refl->getInterfaceNames()); $this->assertContains('Countable', $refl->getInterfaceNames()); }
/** * Get implemented interface names * @return string */ public function getImplements() { $i = $this->reflectionClass->getInterfaceNames(); if (!empty($i)) { return implode(', ', $i); } return ''; }
public function __construct(DiInterface $di, $class) { if (!is_string($class) && !is_object($class)) { throw new Exception("第二个参数只能接受字符串或对象"); } $this->_di = $di; $this->_class = new ReflectionClass($class); if (is_object($class)) { $this->_instance = $class; } elseif (is_string($class) && !$this->_class->isInstantiable()) { throw new Exception("不能对一个无法实例化的类进行注入"); } $this->_interfaceNames = $this->_class->getInterfaceNames(); }
protected function __construct($events = null) { if ($events !== null) { $this->events = $events; return; } static::$definedClasses = get_declared_classes(); $allClass = static::$definedClasses; foreach ($allClass as $key => $className) { $reflectionClass = new \ReflectionClass($className); if (!in_array(EventHander::class, $reflectionClass->getInterfaceNames())) { var_dump($reflectionClass->getInterfaceNames()); } } }
/** * @param \Donquixote\HastyReflectionCommon\Canvas\ClassIndex\ClassIndexInterface $classIndex * @param string $class * * @dataProvider provideClassIndexArgs() */ function testClassIndex(ClassIndexInterface $classIndex, $class) { $classReflection = $classIndex->classGetReflection($class); $reflectionClass = new \ReflectionClass($class); // Test identity. $this->assertTrue($classReflection === $classIndex->classGetReflection($class)); // Test class type/info. $expectedIsClass = !$reflectionClass->isInterface() && !$reflectionClass->isTrait(); $this->assertEquals($reflectionClass->getName(), $classReflection->getName()); $this->assertEquals($reflectionClass->getShortName(), $classReflection->getShortName()); $this->assertEquals($reflectionClass->getDocComment(), $classReflection->getDocComment()); $this->assertEquals($reflectionClass->isInterface(), $classReflection->isInterface()); $this->assertEquals($reflectionClass->isTrait(), $classReflection->isTrait()); $this->assertEquals($expectedIsClass, $classReflection->isClass()); $this->assertEquals($reflectionClass->isAbstract() && $expectedIsClass, $classReflection->isAbstractClass()); // Test context. $this->assertEquals($reflectionClass->getNamespaceName(), $classReflection->getNamespaceUseContext()->getNamespaceName()); // Test interfaces foreach ($classReflection->getOwnInterfaces() as $interfaceName => $interfaceReflection) { $this->assertTrue($reflectionClass->implementsInterface($interfaceName)); } foreach ($reflectionClass->getInterfaceNames() as $interfaceName) { $this->assertTrue($classReflection->extendsOrImplementsInterface($interfaceName, FALSE)); } $expectedAllInterfaceNames = $expectedAllAndSelfInterfaceNames = $reflectionClass->getInterfaceNames(); if ($reflectionClass->isInterface()) { array_unshift($expectedAllAndSelfInterfaceNames, $class); } $this->assertEqualSorted($expectedAllAndSelfInterfaceNames, array_keys($classReflection->getAllInterfaces(TRUE))); $this->assertEqualSorted($expectedAllInterfaceNames, array_keys($classReflection->getAllInterfaces(FALSE))); $expectedMethodNames = array(); $expectedOwnMethodNames = array(); foreach ($reflectionClass->getMethods() as $method) { $expectedMethodNames[] = $method->getName(); if ($method->getDeclaringClass()->getName() === $reflectionClass->getName()) { $expectedOwnMethodNames[] = $method->getName(); } } $this->assertEquals($expectedOwnMethodNames, array_keys($classReflection->getOwnMethods())); $this->assertEqualSorted($expectedMethodNames, array_keys($classReflection->getMethods())); $methodReflections = $classReflection->getMethods(); foreach ($reflectionClass->getMethods() as $reflectionMethod) { $methodReflection = $methodReflections[$reflectionMethod->getShortName()]; $this->assertEqualMethods($reflectionMethod, $methodReflection); } // isAbstract() is a beast, so we test it least. $this->assertEquals($reflectionClass->isAbstract(), $classReflection->isAbstract()); }
public function getAddonRouter($addon, $group = 'content') { if (!isset($this->addonRouters[$addon])) { $addonname = ucfirst($addon); $class = 'PlgTZ_Portfolio_Plus' . ucfirst($group) . $addonname . 'Router'; if (!class_exists($class)) { // Use the component routing handler if it exists $path = JPATH_SITE . '/components/com_tz_portfolio_plus/addons/' . $group . '/' . $addon . '/router.php'; // Use the custom routing handler if it exists if (file_exists($path)) { require_once $path; } } if (class_exists($class)) { $reflection = new ReflectionClass($class); if (in_array('JComponentRouterInterface', $reflection->getInterfaceNames())) { $this->addonRouters[$addon] = new $class($this->app, $this->menu); } } } if (isset($this->addonRouters[$addon]) && $this->addonRouters[$addon]) { return $this->addonRouters[$addon]; } return false; }
/** * Returns the managed template for a given object if one exists, looks for * templates along the object's ancestors until it finds one. If no template * is found, an <code>InvalidArgumentException</code> is thrown. * * @param unknown $object * @throws \InvalidArgumentException * @return multitype: */ public function getManagedTemplate($object) { // ** Collection to hold the list of class names that we are looking for templates in... $classes = array(); // ** Get the object class and push it into the list of classes, also check to see if the array key exists. $objectClass = get_class($object); array_push($classes, $objectClass); if (array_key_exists($objectClass, $this->templateMap)) { return $this->templateMap[$objectClass]; } // ** Search through the ancestors of the object for a matching template... $class = new \ReflectionClass($objectClass); $interfaces = $class->getInterfaceNames(); while ($class = $class->getParentClass()) { $key = $class->getName(); $classes[] = $key; if (array_key_exists($key, $this->templateMap)) { return $this->templateMap[$key]; } } // ** Finally look for a template defined at the interface level... foreach ($interfaces as $interface) { $classes[] = $interface; if (array_key_exists($interface, $this->templateMap)) { return $this->templateMap[$interface]; } } throw new \InvalidArgumentException('Unable to find template for object: ' . $objectClass . ' in the template manager. Looked for template in: ' . implode(', ', $classes)); }
/** * @param object $type * @return string * @throws \Exception */ public function resolve($type) { // @todo remove after MAGETWO-52608 resolved $className = get_class($type); if (isset($this->typeMapping[$className])) { return $this->typeMapping[$className]; } $reflectionClass = new \ReflectionClass($type); $interfaceNames = $reflectionClass->getInterfaceNames(); $dataInterfaces = []; foreach ($interfaceNames as $interfaceName) { if (strpos($interfaceName, '\\Api\\Data\\')) { $dataInterfaces[] = isset($this->config[$interfaceName]) ? $this->config[$interfaceName] : $interfaceName; } } if (count($dataInterfaces) == 0) { throw new \Exception('Unable to determine data interface for ' . $className); } foreach ($dataInterfaces as $dataInterface) { if ($this->metadataPool->hasConfiguration($dataInterface)) { $this->typeMapping[$className] = $dataInterface; } } return $this->typeMapping[$className]; }
/** * Tries to create a new router object for given component, returns NULL * if object not supported * * @staticvar JComponentRouterInterface[] $cache * @param string $component Component name in format "com_xxx" * @return \JComponentRouterInterface */ protected static function getComponentRouter($component) { static $cache = array(); if (!array_key_exists($component, $cache)) { $router = null; $compName = ucfirst(substr($component, 4)); $class = $compName . 'Router'; if (class_exists($class)) { // Check if it supports the Joomla router interface, because // some components use classes with the same name causing // fatal error then (eg. EasyBlog) $reflection = new ReflectionClass($class); if (in_array('JComponentRouterInterface', $reflection->getInterfaceNames())) { // Create the router object $app = JFactory::getApplication(); $menu = $app->getMenu('site'); $router = new $class($app, $menu); } } // If router class not supported, create legacy router object (Joomla 3) if (!$router && class_exists('JComponentRouterLegacy')) { $router = new JComponentRouterLegacy($compName); } // Cache the router object $cache[$component] = $router; } return $cache[$component]; }
static function class_implements($c, $autoload = true) { if (is_object($c)) { $class = get_class($c); } else { if (!class_exists($c, $autoload) && !interface_exists($c, false) && !trait_exists($c, false)) { user_error(__FUNCTION__ . '(): Class ' . $c . ' does not exist and could not be loaded', E_USER_WARNING); return false; } else { $c = self::ns2us($c); } } /**/ if (function_exists('class_implements')) { $autoload = class_implements($c, false); /**/ } else { if (class_exists('ReflectionClass', false)) { $autoload = array(); $c = new ReflectionClass($c); foreach ($c->getInterfaceNames() as $c) { $autoload[$c] = $c; } /**/ } else { return false; /**/ } } foreach ($autoload as $c) { isset(self::$us2ns[$a = strtolower($c)]) && ($autoload[$c] = self::$us2ns[$a]); } return $autoload; }
/** * Fügt mehrere Plugins hinzu und registriert diese bei allen Schnittstellen * @param array $plugins */ public function __construct(array $plugins) { $configCache = new Dragon_Application_Config('dragon/plugin/cache'); $this->_filepath = $configCache->filepath; if (isset($this->_filepath) && is_file($this->_filepath)) { list($this->_plugins, $this->_unsortedplugins, $this->_sortedplugins) = unserialize(file_get_contents($this->_filepath)); } else { foreach ($plugins as $plugin) { if (is_object($plugin)) { $pluginname = get_class($plugin); } else { $pluginname = $plugin; } $this->_plugins[$pluginname] = $pluginname; $reflectionClass = new ReflectionClass($plugin); foreach ($reflectionClass->getInterfaceNames() as $interfacename) { if (!isset($this->_unsortedplugins[$interfacename])) { $this->_unsortedplugins[$interfacename] = array(); } $this->_unsortedplugins[$interfacename][] = $plugin; } } if (isset($this->_filepath)) { file_put_contents($this->_filepath, serialize(array($this->_plugins, $this->_unsortedplugins, $this->_sortedplugins))); } } }
protected function introspectClass(ConfigurableObjectInterface $object) { $originalReflectionClass = $reflectionClass = new \ReflectionClass($object); $this->addClass($reflectionClass->getName()); while (($class = $reflectionClass->getParentClass()) !== false) { $this->addClass($class->getName()); foreach ($class->getInterfaceNames() as $interface) { $this->addClass($interface); $reflectionInterface = new \ReflectionClass($interface); $interfaces = $reflectionInterface->getInterfaceNames(); foreach ($interfaces as $interface) { $this->addClass($interface); } } $reflectionClass = $class; } foreach ($originalReflectionClass->getInterfaceNames() as $name) { $this->addClass($name); $interfaces[] = $name; $reflectionInterface = new \ReflectionClass($name); $theseInterfaces = $reflectionInterface->getInterfaceNames(); $theseInterfaces = array_reverse($theseInterfaces); foreach ($theseInterfaces as $interface) { $this->addClass($interface); } } $this->classes = array_reverse($this->classes); return $this->classes; }
public function emit(...$eventList) { foreach ($eventList as $event) { if (!is_object($event)) { throw new EventBusException(sprintf('EventBus does not support emitting [%s] type.', gettype($event))); } $reflectionClass = new \ReflectionClass($event); $reflectionList = $reflectionClass->getInterfaceNames(); $reflectionList[] = $reflectionClass->getName(); foreach ($reflectionList as $reflection) { if (!isset($this->listenerList[$reflection])) { continue; } foreach ($this->listenerList[$reflection] as $listener) { call_user_func($listener, $event); if ($event instanceof IEvent) { if (!$event->canBubble()) { break 2; } } } } } return $this; }
/** * Get info and details about a module. * * @param $module string with the module name. * @returns array with information on the module. */ private function GetDetailsOfModule($module) { $details = array(); if (class_exists($module)) { $rc = new ReflectionClass($module); $details['name'] = $rc->name; $details['filename'] = $rc->getFileName(); $details['doccomment'] = $rc->getDocComment(); $details['interface'] = $rc->getInterfaceNames(); $details['isController'] = $rc->implementsInterface('IController'); if ($rc->name != 'CMDatabase') { $details['isModel'] = preg_match('/^CM[A-Z]/', $rc->name); } else { $details['isModel'] = ''; } $details['hasSQL'] = $rc->implementsInterface('IHasSQL'); $details['isManageable'] = $rc->implementsInterface('IModule'); $details['isLydiaCore'] = in_array($rc->name, $this->lydiaCoreModules); $details['isLydiaCMF'] = in_array($rc->name, $this->lydiaCMFModules); $details['publicMethods'] = $rc->getMethods(ReflectionMethod::IS_PUBLIC); $details['protectedMethods'] = $rc->getMethods(ReflectionMethod::IS_PROTECTED); $details['privateMethods'] = $rc->getMethods(ReflectionMethod::IS_PRIVATE); $details['staticMethods'] = $rc->getMethods(ReflectionMethod::IS_STATIC); } return $details; }
protected function _checkProtection($protectionType) { // Check type if (!is_string($protectionType) || $protectionType != self::PROTECTION_CSRF && $protectionType != self::PROTECTION_CAPTCHA && $protectionType != self::PROTECTION_BRUTEFORCE && $protectionType != self::PROTECTION_XSS) { throw new \Exception('Invalid protection type : "' . $protectionType . '"'); } // Check class if (class_exists('framework\\security\\form\\' . ucfirst($protectionType))) { $className = 'framework\\security\\form\\' . ucfirst($protectionType); } else { $className = $protectionType; } $class = new \ReflectionClass($className); if (!in_array('framework\\security\\IForm', $class->getInterfaceNames())) { throw new \Exception('Form protection drivers must be implement framework\\security\\IForm'); } if ($class->isAbstract()) { throw new \Exception('Form protection drivers must be not abstract class'); } if ($class->isInterface()) { throw new \Exception('Form protection drivers must be not interface'); } $classInstance = $class->newInstanceWithoutConstructor(); $constuctor = new \ReflectionMethod($classInstance, '__construct'); if ($constuctor->isPrivate() || $constuctor->isProtected()) { throw new \Exception('Protection constructor must be public'); } return $className; }
/** * @param \ReflectionClass|string * @return self */ public static function from($from) { $from = new \ReflectionClass($from instanceof \ReflectionClass ? $from->getName() : $from); if (PHP_VERSION_ID >= 70000 && $from->isAnonymous()) { $class = new static('anonymous'); } else { $class = new static($from->getShortName(), new PhpNamespace($from->getNamespaceName())); } $class->type = $from->isInterface() ? 'interface' : (PHP_VERSION_ID >= 50400 && $from->isTrait() ? 'trait' : 'class'); $class->final = $from->isFinal() && $class->type === 'class'; $class->abstract = $from->isAbstract() && $class->type === 'class'; $class->implements = $from->getInterfaceNames(); $class->documents = $from->getDocComment() ? array(preg_replace('#^\\s*\\* ?#m', '', trim($from->getDocComment(), "/* \r\n\t"))) : array(); if ($from->getParentClass()) { $class->extends = $from->getParentClass()->getName(); $class->implements = array_diff($class->implements, $from->getParentClass()->getInterfaceNames()); } foreach ($from->getProperties() as $prop) { if ($prop->getDeclaringClass()->getName() === $from->getName()) { $class->properties[$prop->getName()] = Property::from($prop); } } foreach ($from->getMethods() as $method) { if ($method->getDeclaringClass()->getName() === $from->getName()) { $class->methods[$method->getName()] = Method::from($method)->setNamespace($class->namespace); } } return $class; }
/** * @author Damien Lasserre <*****@*****.**> * @param string $_adapter * @throws \Exception */ public function __construct($_adapter = null) { /** @var array $_config */ $_config = registry::getInstance()->get('config'); if ($_adapter == null) { $_adapter = $_config['cache_adapter']; } if ($_adapter) { /** @var string $cache */ $cache = 'library\\uranium\\core\\adapter\\cache\\' . $_adapter; if (class_exists($cache)) { /** @var \ReflectionClass $_reflection */ $_reflection = new \ReflectionClass($cache); if (in_array('library\\uranium\\core\\definition\\type\\cache', $_reflection->getInterfaceNames())) { echo 'passe'; } else { throw new \Exception('Your adapter must be extends from library\\uranium\\core\\definition\\type\\cache'); } } else { throw new \Exception('Adapter "' . $_adapter . '" not found'); } } else { throw new \Exception('Please specify a cache adapter'); } }
/** * Gets the interfaces. * * @return \Wingu\OctopusCore\Reflection\ReflectionClass[] */ public function getInterfaces() { $return = array(); foreach (parent::getInterfaceNames() as $interface) { $return[$interface] = new static($interface); } return $return; }
/** * @return ClassType[] */ public function getInterfaces() { $res = array(); foreach (parent::getInterfaceNames() as $val) { $res[$val] = new static($val); } return $res; }
/** * {@inheritDoc} * * use getRealClass if className names a doctrine proxy class. */ public function canonicalName($className) { $refl = new \ReflectionClass($className); if (in_array('Doctrine\\Common\\Persistence\\Proxy', $refl->getInterfaceNames())) { $className = \Doctrine\Common\Util\ClassUtils::getRealClass($className); } return $className; }
/** * Add operator * @param string $operatorClass * @throws \Z\Exception\UnknownOperatorException */ public function addOperator($operatorClass) { $class = new \ReflectionClass($operatorClass); if (!in_array('Z\\Classes\\Token\\InterfaceToken', $class->getInterfaceNames())) { throw new UnknownOperatorException(); } $this->operators[] = $operatorClass; $this->operators = array_unique($this->operators); }
public function preEvent() { foreach ($this->plugins as $p) { $r = new \ReflectionClass(get_class($p)); if (in_array('Empathy\\MVC\\Plugin\\PreEvent', $r->getInterfaceNames())) { $p->onPreEvent(); } } }
public function getInterfaces() { $ifaces = parent::getInterfaceNames(); $result = array(); foreach ($ifaces as $iface) { $result[] = new MyReflectionClass($iface); } return $result; }
private function getJSDescriptor($module, $action) { $class = $this->getActionClass($module, $action); $reflected = new ReflectionClass($class); foreach ($reflected->getInterfaceNames() as $interface) { if ($interface == 'IAppKitDataStoreProviderAction') { return $this->fetchDataStoreDescriptor($class); } } }
/** * Create wait method * * @param ClassModel $classModel * @return null */ private function addWait(ClassModel $classModel) { $reflectionClass = new \ReflectionClass($classModel->getInterface()); if (!in_array('Tebru\\Retrofit\\Http\\AsyncAware', $reflectionClass->getInterfaceNames(), true)) { return null; } $methodModel = new MethodModel($classModel, 'wait'); $methodModel->setBody('$this->client->wait();'); $classModel->addMethod($methodModel); }
public static function registerAutoloader($loaderName, $loaderArguments = array(), $throw = true, $prepend = false, $forceReplace = false) { if (!is_string($loaderName)) { throw new \Exception('LoaderName parameter must be a string'); } if (class_exists('framework\\autoloader\\adaptaters\\' . $loaderName, false)) { $loaderClass = 'framework\\autoloader\\adaptaters\\' . $loaderName; } else { $loaderClass = $loaderName; } // Instantiate loader $loaderInstance = new \ReflectionClass($loaderClass); if (!in_array('framework\\autoloader\\IAdaptater', $loaderInstance->getInterfaceNames())) { throw new \Exception('Loader class must be implement framework\\autoloader\\IAdaptater'); } if ($loaderInstance->isAbstract()) { throw new \Exception('Loader class must be not abstract class'); } if ($loaderInstance->isInterface()) { throw new \Exception('Loader class must be not interface'); } // Check if is already registered if (self::isRegisteredAutoloader($loaderInstance->getShortName()) && !$forceReplace) { throw new \Exception('Loader is already registered'); } // Checking arguments for create an instance with good parameters if (count($loaderArguments) > 1) { $loaderConstructor = new \ReflectionMethod($loaderClass, '__construct'); $params = $loaderConstructor->getParameters(); $cleanedLoaderArguments = array(); foreach ($params as $key => $param) { if ($param->isPassedByReference()) { $cleanedLoaderArguments[$key] =& $loaderArguments[$key]; } else { $cleanedLoaderArguments[$key] = $loaderArguments[$key]; } } $loader = $loaderInstance->newInstanceArgs($cleanedLoaderArguments); } else { $loader = $loaderInstance->newInstance(); } // Register spl autoload if (!function_exists('spl_autoload_register')) { throw new \Exception('spl_autoload_register does not exists in this PHP installation'); } if (!is_bool($throw)) { throw new \Exception('throw parameter must be an boolean'); } if (!is_bool($prepend)) { throw new \Exception('prepend parameter must be an boolean'); } spl_autoload_register(array($loader, 'autoload'), $throw, $prepend); // Stock self::$_autoloaders[$loaderInstance->getShortName()] = $loader; }
/** * {@inheritDoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $defaults = Yaml::parse(__DIR__ . '/../Resources/config/cms/config.yml'); foreach ($configs as $config) { foreach ($config as $key => $value) { $defaults['networking_init_cms'][$key] = $value; } } $config = $this->processConfiguration($configuration, $defaults); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('blocks.xml'); $loader->load('dynamic_routing.xml'); $loader->load('event_listeners.xml'); $loader->load('forms.xml'); $loader->load('menus.xml'); $loader->load('twig.xml'); $loader->load('services.xml'); $loader->load('validators.xml'); //mongodb is not yet fully supported but will come (eventually) if ('custom' !== $config['db_driver']) { $loader->load(sprintf('doctrine_%s.xml', $config['db_driver'])); $loader->load(sprintf('ext_admin_%s.xml', $config['db_driver'])); $loader->load(sprintf('admin_%s.xml', $config['db_driver'])); } $config['languages'] = $this->addShortLabels($config['languages']); $container->setParameter('networking_init_cms.page.languages', $config['languages']); $container->setParameter('networking_init_cms.page.templates', $config['templates']); $container->setParameter('networking_init_cms.page.content_types', $config['content_types']); $container->setParameter('networking_init_cms.translation_fallback_route', $config['translation_fallback_route']); if (!$config['admin_toolbar']['toolbar']) { $mode = AdminToolbarListener::DISABLED; } else { $mode = AdminToolbarListener::ENABLED; } $container->setParameter('networking_init_cms.admin_toolbar.mode', $mode); $container->setParameter('networking_init_cms.admin_toolbar.position', $config['admin_toolbar']['position']); $container->setParameter('networking_init_cms.404_template', $config['404_template']); $container->setParameter('networking_init_cms.no_translation_template', $config['no_translation_template']); $container->setParameter('networking_init_cms.admin_menu_groups', $config['admin_menu_groups']); $container->setParameter('networking_init_cms.db_driver', $config['db_driver']); if ($config['db_driver'] == 'orm') { $this->registerDoctrineORMMapping($config, $container); } $container->setParameter('networking_init_cms.cache.activate', $config['cache']['activate']); $container->setParameter('networking_init_cms.cache.cache_time', $config['cache']['cache_time']); $cacheClass = $config['cache']['cache_service_class']; $reflectionClass = new \ReflectionClass($cacheClass); if (in_array('Networking\\InitCmsBundle\\Lib\\PhpCacheInterface', $reflectionClass->getInterfaceNames())) { $container->setParameter('networking_init_cms.lib.php_cache.class', $config['cache']['cache_service_class']); } else { throw new InvalidParameterException('Cache class should implement the PhpCacheInterface interface'); } $this->configureClass($config, $container); }
/** * Set the url resolver class used for http requests * * @param string $className */ public function setResolverClass($className) { if (!class_exists($className)) { throw new \Exception("This class does not exists"); } $reflection = new \ReflectionClass($className); if (!in_array('Embed\\RequestResolvers\\RequestResolverInterface', $reflection->getInterfaceNames())) { throw new \Exception("The resolver class must implement the Embed\\RequestResolvers\\RequestResolverInterface interface"); } $this->resolverClass = $className; }
/** * Returns an array of all implemented interfaces * * @return array */ protected function _getInterfaceNames() { $interfaces = $this->_reflection_class->getInterfaceNames(); $namespace = $this->_reflection_class->getNamespaceName(); array_walk($interfaces, function (&$name) use($namespace) { if (!empty($namespace) && strpos($name, '\\') === false) { $name = '\\' . $name; } }); return $interfaces; }