@@ -28,19 +28,28 @@ class GraphComposer
28
28
'style ' => 'dashed '
29
29
);
30
30
31
+ private $ dependencyGraph ;
32
+
31
33
/**
32
34
*
33
35
* @param string $dir
34
- * @return \Fhaculty\Graph\Graph
35
36
*/
36
- public function createGraph ($ dir )
37
+ public function __construct ($ dir )
37
38
{
38
39
$ analyzer = new \JMS \Composer \DependencyAnalyzer ();
39
- $ dependencyGraph = $ analyzer ->analyze ($ dir );
40
-
40
+ $ this ->dependencyGraph = $ analyzer ->analyze ($ dir );
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @param string $dir
46
+ * @return \Fhaculty\Graph\Graph
47
+ */
48
+ public function createGraph ()
49
+ {
41
50
$ graph = new Graph ();
42
51
43
- foreach ($ dependencyGraph ->getPackages () as $ package ) {
52
+ foreach ($ this -> dependencyGraph ->getPackages () as $ package ) {
44
53
$ name = $ package ->getName ();
45
54
$ start = $ graph ->createVertex ($ name , true );
46
55
@@ -65,14 +74,14 @@ public function createGraph($dir)
65
74
}
66
75
}
67
76
68
- $ graph ->getVertex ($ dependencyGraph ->getRootPackage ()->getName ())->setLayout ($ this ->layoutVertexRoot );
77
+ $ graph ->getVertex ($ this -> dependencyGraph ->getRootPackage ()->getName ())->setLayout ($ this ->layoutVertexRoot );
69
78
70
79
return $ graph ;
71
80
}
72
81
73
- public function displayGraph ($ dir )
82
+ public function displayGraph ()
74
83
{
75
- $ graph = $ this ->createGraph ($ dir );
84
+ $ graph = $ this ->createGraph ();
76
85
77
86
$ graphviz = new GraphViz ($ graph );
78
87
$ graphviz ->setFormat ('svg ' );
0 commit comments