Skip to content

Instantly share code, notes, and snippets.

@cornernote
Created August 8, 2015 16:47
Show Gist options
  • Save cornernote/97e7c34389ab7755be64 to your computer and use it in GitHub Desktop.
Save cornernote/97e7c34389ab7755be64 to your computer and use it in GitHub Desktop.
<?php
namespace app\components;
class Git
{
public static function get($endpoint, $file)
{
if (strpos($endpoint, 'github.com')) {
$https = strtr($endpoint, [
'git://' => 'https://raw.',
'.git' => '/master/' . $file,
]);
return @file_get_contents($https);
}
if (strpos($endpoint, 'bitbucket.org')) {
$https = strtr($endpoint, [
'git://' => 'https://',
'.git' => '/raw/master/' . $file,
]);
return @file_get_contents($https);
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment