class ForkRemote
{
+ /**
+ * Contains error message when parse() failed
+ */
+ public $error;
+
protected $url;
/**
public function __construct($url)
{
- $this->url = $url;
+ $this->url = trim($url);
}
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'
}
}
- return $count > 0;
+ if ($count > 0) {
+ return true;
+ }
+
+ $this->error = 'No git:// clone URL found';
+ return false;
}
/**