ggoffy /
wggithub
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace XoopsModules\Wggithub\Github; |
||||
| 6 | |||||
| 7 | /* |
||||
| 8 | * You may not change or alter any portion of this comment or credits |
||||
| 9 | * of supporting developers from this source code or any supporting source code |
||||
| 10 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 11 | * |
||||
| 12 | * This program is distributed in the hope that it will be useful, |
||||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 15 | */ |
||||
| 16 | /** |
||||
| 17 | * @copyright XOOPS Project https://xoops.org/ |
||||
| 18 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||||
| 19 | * @since |
||||
| 20 | * @author Goffy - XOOPS Development Team |
||||
| 21 | */ |
||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * Class GitHub |
||||
| 25 | */ |
||||
| 26 | class GitHub extends GitHubClient |
||||
| 27 | {
|
||||
| 28 | |||||
| 29 | public const BASE_URL = 'https://api.github.com/'; |
||||
| 30 | /** |
||||
| 31 | * @var string |
||||
| 32 | */ |
||||
| 33 | public $user = 'myusername'; |
||||
| 34 | /** |
||||
| 35 | * @var string |
||||
| 36 | */ |
||||
| 37 | public $token = 'mytoken'; |
||||
| 38 | /** |
||||
| 39 | * Verbose debugging for curl (when putting) |
||||
| 40 | * @var bool |
||||
| 41 | */ |
||||
| 42 | public $debug = false; |
||||
| 43 | |||||
| 44 | /** |
||||
| 45 | * Constructor |
||||
| 46 | * |
||||
| 47 | * @param null |
||||
| 48 | */ |
||||
| 49 | public function __construct() |
||||
| 50 | {
|
||||
| 51 | $this->getSetting(); |
||||
| 52 | } |
||||
| 53 | |||||
| 54 | /** |
||||
| 55 | * @static function &getInstance |
||||
| 56 | * |
||||
| 57 | * @param null |
||||
| 58 | * @return GitHub of GitHub |
||||
| 59 | */ |
||||
| 60 | public static function getInstance() |
||||
| 61 | {
|
||||
| 62 | static $instance = false; |
||||
| 63 | if (!$instance) {
|
||||
| 64 | $instance = new self(); |
||||
| 65 | } |
||||
| 66 | |||||
| 67 | return $instance; |
||||
| 68 | } |
||||
| 69 | |||||
| 70 | /** |
||||
| 71 | * Get data of all repositories of given user |
||||
| 72 | * |
||||
| 73 | * @param string $user |
||||
| 74 | * @return array |
||||
| 75 | |||||
| 76 | public function readUserRepositories($user) |
||||
| 77 | {
|
||||
| 78 | $githubLib = new Repositories(); |
||||
| 79 | $repos = $githubLib->getUserRepositories($user); |
||||
| 80 | |||||
| 81 | return $repos; |
||||
| 82 | } |
||||
| 83 | */ |
||||
| 84 | |||||
| 85 | /** |
||||
| 86 | * Get data of all repositories of given organisation |
||||
| 87 | * |
||||
| 88 | * @param $org |
||||
| 89 | * @return array |
||||
| 90 | |||||
| 91 | public function readOrgRepositories($org) |
||||
| 92 | {
|
||||
| 93 | $githubLib = new Repositories(); |
||||
| 94 | $repos = $githubLib->getOrgRepositories($org); |
||||
| 95 | |||||
| 96 | return $repos; |
||||
| 97 | } |
||||
| 98 | */ |
||||
| 99 | |||||
| 100 | /** |
||||
| 101 | * Get primary setting |
||||
| 102 | * |
||||
| 103 | * @param bool $user |
||||
| 104 | * @return bool|array |
||||
| 105 | */ |
||||
| 106 | private function getSetting($user = false) |
||||
| 107 | {
|
||||
| 108 | $helper = Helper::getInstance(); |
||||
| 109 | $settingsHandler = $helper->getHandler('Settings');
|
||||
| 110 | if ($user) {
|
||||
| 111 | $setting = $settingsHandler->getRequestSetting(); |
||||
| 112 | } else {
|
||||
| 113 | $setting = $settingsHandler->getPrimarySetting(); |
||||
| 114 | } |
||||
| 115 | |||||
| 116 | if (0 == \count($setting)) {
|
||||
| 117 | \redirect_header('settings.php', 3, \_AM_WGTRANSIFEX_THEREARENT_SETTINGS);
|
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 118 | } |
||||
| 119 | |||||
| 120 | return $setting; |
||||
| 121 | } |
||||
| 122 | |||||
| 123 | |||||
| 124 | } |
||||
| 125 |