Neos\Flow\Reflection\ReflectionService::isClassImplementationOf PHP Метод

isClassImplementationOf() публичный Метод

Tells if the specified class implements the given interface
public isClassImplementationOf ( string $className, string $interfaceName ) : boolean
$className string Name of the class
$interfaceName string interface to check for
Результат boolean TRUE if the class implements $interfaceName, otherwise FALSE
    public function isClassImplementationOf($className, $interfaceName)
    {
        $className = $this->prepareClassReflectionForUsage($className);
        $interfaceName = $this->cleanClassName($interfaceName);
        $this->loadOrReflectClassIfNecessary($interfaceName);
        return isset($this->classReflectionData[$interfaceName][self::DATA_INTERFACE_IMPLEMENTATIONS][$className]);
    }

Usage Example

 /**
  * Returns instance of concrete formatter.
  *
  * The type provided has to be either a name of existing class placed in
  * I18n\Formatter namespace or a fully qualified class name;
  * in both cases implementing this' package's FormatterInterface.
  * For example, when $formatterName is 'number',
  * the I18n\Formatter\NumberFormatter class has to exist; when
  * $formatterName is 'Acme\Foobar\I18nFormatter\SampleFormatter', this class
  * must exist and implement I18n\Formatter\FormatterInterface.
  *
  * Throws exception if there is no formatter for name given or one could be
  * retrieved but does not satisfy the FormatterInterface.
  *
  * @param string $formatterType Either one of the built-in formatters or fully qualified formatter class name
  * @return Formatter\FormatterInterface The concrete formatter class
  * @throws Exception\UnknownFormatterException When formatter for a name given does not exist
  * @throws Exception\InvalidFormatterException When formatter for a name given does not exist
  */
 protected function getFormatter($formatterType)
 {
     $foundFormatter = false;
     $formatterType = ltrim($formatterType, '\\');
     if (isset($this->formatters[$formatterType])) {
         $foundFormatter = $this->formatters[$formatterType];
     }
     if ($foundFormatter === false) {
         if ($this->objectManager->isRegistered($formatterType)) {
             $possibleClassName = $formatterType;
         } else {
             $possibleClassName = sprintf('Neos\\Flow\\I18n\\Formatter\\%sFormatter', ucfirst($formatterType));
             if (!$this->objectManager->isRegistered($possibleClassName)) {
                 throw new Exception\UnknownFormatterException('Could not find formatter for "' . $formatterType . '".', 1278057791);
             }
         }
         if (!$this->reflectionService->isClassImplementationOf($possibleClassName, Formatter\FormatterInterface::class)) {
             throw new Exception\InvalidFormatterException(sprintf('The resolved internationalization formatter class name "%s" does not implement "%s" as required.', $possibleClassName, FormatterInterface::class), 1358162557);
         }
         $foundFormatter = $this->objectManager->get($possibleClassName);
     }
     $this->formatters[$formatterType] = $foundFormatter;
     return $foundFormatter;
 }
All Usage Examples Of Neos\Flow\Reflection\ReflectionService::isClassImplementationOf
ReflectionService