php-hotfix/src/Hotfix/Loader/PastebinLoader.php

29 lines
560 B
PHP
Raw Normal View History

2016-04-19 13:54:03 +00:00
<?php
namespace NoccyLabs\Hotfix\Hotfix\Loader;
class PastebinLoader implements LoaderInterface
{
public function load($fix)
{
if (!preg_match('/^pastebin\:/i', $fix)) {
return false;
}
2016-04-19 14:30:47 +00:00
$pasteId = substr($fix, 9);
$url = "https://pastebin.com/raw/{$pasteId}";
$body = file_get_contents($url);
$body = str_replace("\r\n", "\n", $body);
return $body;
2016-04-19 13:54:03 +00:00
}
2016-04-19 20:55:09 +00:00
public function getInfo()
{
return "pastebin:<info>paste-id</info> - Read hotfix from Pastebin";
}
2016-04-19 13:54:03 +00:00
}