/** * @param string $class * @param null|string $alias * @param bool $checkClassExists Use FALSE when you want to use a namespace instead of a class * * @return $this * @throws Exception\ClassUse When the given class does not exists */ public function addUse($class, $alias = null, $checkClassExists = true) { if ($checkClassExists === true && $this->classFile->isClassDefined("\\{$class}") === false && $this->classFile->isInterfaceDefined("\\{$class}") === false && $this->classFile->isTraitDefined("\\{$class}") === false) { throw Exception\ClassUse::classUseNotFound($class); } $use = new ClassUse($class, $alias); $this->append($use); return $this; }
/** * Checks if the interface is defined or not * * @param string $interface * * @return boolean */ protected function isInterfaceDefined($interface) { return $this->classFile->isInterfaceDefined($interface); }