Exemplo n.º 1
0
 /**
  * Adds a class to the file
  *
  * @param PhpClass $class The class to add
  * @throws Exception If the class already exists
  */
 public function addClass(PhpClass $class)
 {
     if ($this->classExists($class->getIdentifier())) {
         throw new Exception('A class of the name (' . $class->getIdentifier() . ') does already exist.');
     }
     $this->classes[$class->getIdentifier()] = $class;
 }
 /**
  * Checks if the class is approved
  * Removes the prefix and suffix for namechecking
  *
  * @param PhpClass $class
  * @return bool Returns true if the class is ok to add to file
  */
 private function isValidClass(PhpClass $class)
 {
     $classNames = $this->config->get('classNames');
     return empty($classNames) || in_array($class->getIdentifier(), $classNames);
 }
 /**
  * Checks if the class is approved
  * Removes the prefix and suffix for namechecking
  *
  * @param PhpClass $class
  * @return bool Returns true if the class is ok to add to file
  */
 private function isValidClass(PhpClass $class)
 {
     $suffix = strlen($this->config->getSuffix());
     if ($suffix > 0) {
         $nSuf = 0 - $suffix;
         $className = substr($class->getIdentifier(), strlen($this->config->getPrefix()), $nSuf);
     } else {
         $className = substr($class->getIdentifier(), strlen($this->config->getPrefix()));
     }
     if (count($this->classesToSave) == 0 || count($this->classesToSave) > 0 && in_array($className, $this->classesToSave)) {
         return true;
     }
     return false;
 }