File tree Expand file tree Collapse file tree 3 files changed +47
-6
lines changed
Expand file tree Collapse file tree 3 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ public function factory(InputInterface $input) {
6262 strlen ($ input ->getOption ('offline ' )) > 0 && $ config ->getTemplate ()->setOffline ($ input ->getOption ('offline ' ));
6363 strlen ($ input ->getOption ('ignore-errors ' )) > 0 && $ config ->setIgnoreErrors (true );
6464
65+ // check for conflicts or missing requirements
66+ $ validator = new ConfigValidator ();
67+ $ validator ->validates ($ config );
68+
6569 return $ config ;
6670
6771 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * (c) Jean-François Lépine <https://twitter.com/Halleck45>
5+ *
6+ * For the full copyright and license information, please view the LICENSE
7+ * file that was distributed with this source code.
8+ */
9+
10+ namespace Hal \Application \Config ;
11+ use Hal \Component \Chart \Graphviz ;
12+ use Hal \Component \Config \Hydrator ;
13+ use Hal \Component \Config \Loader ;
14+ use Hal \Component \Config \Validator ;
15+ use Symfony \Component \Console \Input \InputInterface ;
16+
17+ /**
18+ * Config checker
19+ *
20+ * @author Jean-François Lépine <https://twitter.com/Halleck45>
21+ */
22+ class ConfigValidator
23+ {
24+ /**
25+ * @param Configuration $config
26+ */
27+ public function validates (Configuration $ config )
28+ {
29+ // graphviz
30+ if ($ config ->getLogging ()->getChart ('bubbles ' )) {
31+ $ graphviz = new Graphviz ();
32+ if (!$ graphviz ->isAvailable ()) {
33+ throw new \RuntimeException ('Graphviz not installed ' );
34+ }
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -20,13 +20,11 @@ class Graphviz
2020 /**
2121 * Checks installation of graphviz
2222 *
23- * @throws \RuntimeException
23+ * @return boolean
2424 */
25- public function checkInstallation () {
25+ public function isAvailable () {
2626 $ result = shell_exec ('circo -V 2>&1 ' );
27- if (!preg_match ('!graphviz version! ' , $ result )) {
28- throw new \RuntimeException ('Graphviz not installed ' );
29- }
27+ return preg_match ('!graphviz version! ' , $ result );
3028 }
3129
3230 /**
@@ -37,7 +35,9 @@ public function checkInstallation() {
3735 */
3836 public function getImage ($ dotContent ) {
3937
40- $ this ->checkInstallation ();
38+ if (!$ this ->isAvailable ()) {
39+ throw new \RuntimeException ('Graphviz not installed ' );
40+ }
4141
4242 $ dotFile = tempnam (sys_get_temp_dir (), 'phpmetrics-graphviz ' );
4343 $ imageFile = tempnam (sys_get_temp_dir (), 'phpmetrics-graphviz ' );
You can’t perform that action at this time.
0 commit comments