Created
August 8, 2015 16:47
-
-
Save cornernote/97e7c34389ab7755be64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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