diff --git a/bin/php-class-diagram b/bin/php-class-diagram index 5ca31b3..9f539c1 100755 --- a/bin/php-class-diagram +++ b/bin/php-class-diagram @@ -88,7 +88,7 @@ if (empty($directory)) { fwrite(STDERR, $usage); exit(-1); } -if (!is_dir($directory)) { +if (!file_exists($directory)) { fwrite(STDERR, sprintf("ERROR: specified directory dose not exists. directory: %s\n", $directory)); fwrite(STDERR, $usage); exit(-1); diff --git a/src/Main.php b/src/Main.php index 6fd8907..d36e887 100644 --- a/src/Main.php +++ b/src/Main.php @@ -30,6 +30,14 @@ public function run(): void private function createFinder(): Finder { + if (is_file($this->directory)) { + $finder = new Finder(); + $finder->files()->in(dirname($this->directory)); + $finder->files()->name($this->options->includes()); + + return $finder; + } + $finder = new Finder(); $finder->files()->in($this->directory); $finder->files()->name($this->options->includes()); @@ -62,6 +70,7 @@ private function findEntries(Finder $finder): array fwrite(STDERR, $e->getMessage() . "\r\n"); } } + return $entries; } @@ -74,9 +83,9 @@ private function renderEntries(array $entries): void match ($this->options->diagram()) { Options::DIAGRAM_CLASS => $this->renderDiagramClass($relation), - OPTIONS::DIAGRAM_PACKAGE => $this->renderDiagramPackage($relation), - OPTIONS::DIAGRAM_JIG => $this->renderDiagramJig($relation), - OPTIONS::DIAGRAM_DIVISION => $this->renderDiagramDivision($relation), + Options::DIAGRAM_PACKAGE => $this->renderDiagramPackage($relation), + Options::DIAGRAM_JIG => $this->renderDiagramJig($relation), + Options::DIAGRAM_DIVISION => $this->renderDiagramDivision($relation), default => throw new RuntimeException('invalid diagram.') }; }