move load method to top
[phorkie.git] / src / phorkie / ForkRemote.php
index 3f6a4787ce818f89d4b37a940ffc5abcd0ff126e..7f6129d9a524cefe134e116a2ac6ffd4014b2dbf 100644 (file)
@@ -3,6 +3,11 @@ namespace phorkie;
 
 class ForkRemote
 {
+    /**
+     * Contains error message when parse() failed
+     */
+    public $error;
+
     protected $url;
 
     /**
@@ -22,8 +27,13 @@ class ForkRemote
 
     public function parse()
     {
+        if ($this->url == '') {
+            $this->error = 'Empty fork URL';
+            return false;
+        }
+
         $arUrl  = parse_url($this->url);
-        $scheme = $arUrl['scheme'] ?: '';
+        $scheme = isset($arUrl['scheme']) ? $arUrl['scheme'] : '';
 
         if ($scheme == 'https' && isset($arUrl['host'])
             && $arUrl['host'] == 'gist.github.com'
@@ -85,7 +95,12 @@ class ForkRemote
             }
         }
 
-        return $count > 0;
+        if ($count > 0) {
+            return true;
+        }
+
+        $this->error = 'No git:// clone URL found';
+        return false;
     }
 
     /**