/**
  * Constructor.
  *
  * @param string $inClassName
  * @param string $inSourceFile
  * @param string $outClassName
  * @param string $outSourceFile
  * @throws RuntimeException
  */
 public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '')
 {
     if (empty($inSourceFile)) {
         $inSourceFile = $inClassName . '.php';
     }
     if (!is_file($inSourceFile)) {
         throw new RuntimeException(sprintf('"%s" could not be opened.', $inSourceFile));
     }
     if (empty($outClassName)) {
         $outClassName = substr($inClassName, 0, strlen($inClassName) - 4);
     }
     if (empty($outSourceFile)) {
         $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php';
     }
     parent::__construct($inClassName, $inSourceFile, $outClassName, $outSourceFile);
 }
Exemple #2
0
 /**
  * Constructor.
  *
  * @param string $inClassName
  * @param string $inSourceFile
  * @param string $outClassName
  * @param string $outSourceFile
  * @throws RuntimeException
  */
 public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '')
 {
     if (class_exists($inClassName)) {
         $reflector = new ReflectionClass($inClassName);
         $inSourceFile = $reflector->getFileName();
         if ($inSourceFile === FALSE) {
             $inSourceFile = '<internal>';
         }
         unset($reflector);
     } else {
         if (empty($inSourceFile)) {
             $possibleFilenames = array($inClassName . '.php', str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $inClassName) . '.php');
             foreach ($possibleFilenames as $possibleFilename) {
                 if (is_file($possibleFilename)) {
                     $inSourceFile = $possibleFilename;
                 }
             }
         }
         if (empty($inSourceFile)) {
             throw new RuntimeException(sprintf('Neither "%s" nor "%s" could be opened.', $possibleFilenames[0], $possibleFilenames[1]));
         }
         if (!is_file($inSourceFile)) {
             throw new RuntimeException(sprintf('"%s" could not be opened.', $inSourceFile));
         }
         $inSourceFile = realpath($inSourceFile);
         include_once $inSourceFile;
         if (!class_exists($inClassName)) {
             throw new RuntimeException(sprintf('Could not find class "%s" in "%s".', $inClassName, $inSourceFile));
         }
     }
     if (empty($outClassName)) {
         $outClassName = $inClassName . 'Test';
     }
     if (empty($outSourceFile)) {
         $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php';
     }
     parent::__construct($inClassName, $inSourceFile, $outClassName, $outSourceFile);
 }