canRead($pFilename)) { return $reader->load($pFilename); } } throw new \Exception("Could not automatically determine \PhpOffice\PhpPresentation\Reader\ReaderInterface for file."); } /** * Load class * * @param string $class * @param string $name * @param string $type * @param \PhpOffice\PhpPresentation\PhpPresentation $phpPresentation * @return mixed * @throws \ReflectionException */ private static function loadClass($class, $name, $type, PhpPresentation $phpPresentation = null) { if (class_exists($class) && self::isConcreteClass($class)) { if (is_null($phpPresentation)) { return new $class(); } else { return new $class($phpPresentation); } } else { throw new \Exception('"'.$name.'" is not a valid '.$type.'.'); } } /** * Is it a concrete class? * * @param string $class * @return bool * @throws \ReflectionException */ private static function isConcreteClass($class) { $reflection = new \ReflectionClass($class); return !$reflection->isAbstract() && !$reflection->isInterface(); } }