Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ PHP GraphML Generator

Install in your project with composer

```
$ composer require ramoty/graphml_generator
```

Usage

Em ./vendor/ramoty/graphml_generator/graphml_generator.php
Open ./vendor/ramoty/graphml_generator/graphml_generator.php

altere se necessario

$sPathForSourceCodeFiles = dirname(__FILE__ ) . '/../../../'; // project root

$graphResults = 'docs/graphResults'; // saved and created at the root of the project docs/graphResults

$sPathForSourceCodeFilesExclude = 'vendor'; // Delete the directory of the generation
Change as needed:
* $sPathForSourceCodeFiles = dirname(__FILE__ ) . '/../../../'; // project root
* $graphResults = 'docs/graphResults'; // saved and created at the root of the project docs/graphResults
* $sPathForSourceCodeFilesExclude = ['vendor']; // exlude directories with any of those names

Execute

```
$ php ./vendor/ramoty/graphml_generator/graphml_generator.php
```

to view the generated $ graphResults file, visit https://www.yworks.com/yed-live/
To view the generated $ graphResults file, visit https://www.yworks.com/yed-live/
12 changes: 6 additions & 6 deletions graphml_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class generateGraphML
* @param string $sDirectory Initial directory, this is the first dir where .php files will be searched
* @param string $sExcludeDir Don't read directories matching $sExcludeDir
*/
public function __construct($sDirectory = '.', $sDirResult = './graphResults', $sExcludeDir = '')
public function __construct($sDirectory = '.', $sDirResult = './graphResults', $sExcludeDirs = [''])
{
echo "Path for Generated .graphml files: <b>$sDirResult</b> <br>\n";
$this->sBaseDir = dirname(__FILE__ ) . '/';
Expand Down Expand Up @@ -153,7 +153,7 @@ public function __construct($sDirectory = '.', $sDirResult = './graphResults', $
}

/* Search for .php files */
$this->walkDir($this->sDirectory, $sExcludeDir);
$this->walkDir($this->sDirectory, $sExcludeDirs);

/* Create edges between objects inheritance */
$this->createEdges();
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function collectFiles($sDirectory = '.')
* @param string $sDirectory Search for .php files in $sDirectory
* @param string $sExcludeDir (optional) Don't read directories matching $sExcludeDir
*/
protected function walkDir($sDirectory, $sExcludeDir = '')
protected function walkDir($sDirectory, $sExcludeDirs = [''])
{
if ($rDh = opendir($sDirectory))
{
Expand All @@ -208,13 +208,13 @@ protected function walkDir($sDirectory, $sExcludeDir = '')
if ($sCurrentFile == '.' || $sCurrentFile == '..')
continue;

if ($sCurrentFile == $sExcludeDir)
if (in_array($sCurrentFile, $sExcludeDirs))
continue;

if (is_dir($sDirectory . '/' . $sCurrentFile))
{
/* Current file is a directory, so entering into it */
$this->walkDir($sDirectory . '/' . $sCurrentFile, $sExcludeDir);
$this->walkDir($sDirectory . '/' . $sCurrentFile, $sExcludeDirs);

/* Search and parse .php files in the given directory */
$this->collectFiles($sDirectory . '/' . $sCurrentFile);
Expand Down Expand Up @@ -548,7 +548,7 @@ protected function createFullGraphML()

$sPathForSourceCodeFiles = dirname(__FILE__ ) . '/../../../'; // project root
$graphResults = 'docs/graphResults'; // saved and created at the root of the project docs/graphResults
$sPathForSourceCodeFilesExclude = 'vendor'; //
$sPathForSourceCodeFilesExclude = ['vendor']; // exlude directories with any of those names
echo "Path For Source Code Files To Read: <b>$sPathForSourceCodeFiles</b><br>";

$oGraphMLGenerator = new generateGraphML($sPathForSourceCodeFiles, $graphResults, $sPathForSourceCodeFilesExclude);