@@ -53,6 +53,8 @@ class Graph
5353 /** @var \phpDocumentor\GraphViz\Edge[] A list of edges / arrows for this Graph */
5454 protected $ edges = array ();
5555
56+ protected $ path = '' ;
57+
5658 /**
5759 * Factory method to instantiate a Graph so that you can use fluent coding
5860 * to chain everything.
@@ -72,6 +74,21 @@ public static function create($name = 'G', $directional = true)
7274 return $ graph ;
7375 }
7476
77+ /**
78+ * Sets the path for the execution. Only needed if it is not in the PATH env.
79+ *
80+ * @param string $path The path to execute dot from
81+ *
82+ * @return \phpDocumentor\GraphViz\Graph
83+ */
84+ public function setPath ($ path )
85+ {
86+ if ($ path && $ path = realpath ($ path )) {
87+ $ this ->path = $ path . DIRECTORY_SEPARATOR ;
88+ }
89+ return $ this ;
90+ }
91+
7592 /**
7693 * Sets the name for this graph.
7794 *
@@ -149,12 +166,12 @@ public function getType()
149166 function __call ($ name , $ arguments )
150167 {
151168 $ key = strtolower (substr ($ name , 3 ));
152- if (strtolower (substr ($ name , 0 , 3 )) == 'set ' ) {
169+ if (strtolower (substr ($ name , 0 , 3 )) === 'set ' ) {
153170 $ this ->attributes [$ key ] = new Attribute ($ key , $ arguments [0 ]);
154171
155172 return $ this ;
156173 }
157- if (strtolower (substr ($ name , 0 , 3 )) == 'get ' ) {
174+ if (strtolower (substr ($ name , 0 , 3 )) === 'get ' ) {
158175 return $ this ->attributes [$ key ];
159176 }
160177
@@ -320,12 +337,12 @@ public function export($type, $filename)
320337 file_put_contents ($ tmpfile , (string )$ this );
321338
322339 // escape the temp file for use as argument
323- $ tmpfile_arg = escapeshellarg ($ tmpfile );
340+ $ tmpfileArg = escapeshellarg ($ tmpfile );
324341
325342 // create the dot output
326343 $ output = array ();
327344 $ code = 0 ;
328- exec ("dot -T $ type -o $ filename < $ tmpfile_arg 2>&1 " , $ output , $ code );
345+ exec ($ this -> path . "dot -T $ type -o $ filename < $ tmpfileArg 2>&1 " , $ output , $ code );
329346 unlink ($ tmpfile );
330347
331348 if ($ code != 0 ) {
0 commit comments