From 79bc0a92d9afa536dc0a098ecf8b63bdddb6635a Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Tue, 19 Apr 2016 16:30:47 +0200 Subject: [PATCH] Implemented gist and pastebin loaders --- src/Hotfix/Loader/GistLoader.php | 5 +++++ src/Hotfix/Loader/PastebinLoader.php | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Hotfix/Loader/GistLoader.php b/src/Hotfix/Loader/GistLoader.php index e45c050..c9d13c9 100644 --- a/src/Hotfix/Loader/GistLoader.php +++ b/src/Hotfix/Loader/GistLoader.php @@ -9,5 +9,10 @@ class GistLoader implements LoaderInterface if (!preg_match('/^gist\:/i', $fix)) { return false; } + + $url = "https://gist.githubusercontent.com/" . substr($fix, 5) . "/raw"; + + return file_get_contents($url); + } } diff --git a/src/Hotfix/Loader/PastebinLoader.php b/src/Hotfix/Loader/PastebinLoader.php index 01ec08b..a6ddf71 100644 --- a/src/Hotfix/Loader/PastebinLoader.php +++ b/src/Hotfix/Loader/PastebinLoader.php @@ -9,5 +9,15 @@ class PastebinLoader implements LoaderInterface if (!preg_match('/^pastebin\:/i', $fix)) { return false; } + + $pasteId = substr($fix, 9); + + $url = "https://pastebin.com/raw/{$pasteId}"; + $body = file_get_contents($url); + + $body = str_replace("\r\n", "\n", $body); + + return $body; + } }