GitHubAPI
MMO\git · 1 symbol · generated 5 Oct 2026
GitHubAPI
GitHubAPI.php:29A thin client for the GitHub REST API, for the things a repository cannot answer on its own: pull requests, issues, releases and the state of a branch on the server. It reads all of them, and writes issues, and the labels and milestones they use (IssueBoard shows them as a kanban board).
- Namespace
MMO\git- Extends
- aModule
Index
Constants1
API_VERSION
Properties5
repository
token
url
- Type
- string
user
userAgent
- Type
- string
Methods37
assertRepository($repository)
GitHubAPI.php:201createComment($number, $body, $repository)
GitHubAPI.php:297createIssue($fields, $repository)
GitHubAPI.php:261Open an issue. Needs a token allowed to write the repository's issues.
| $fields | array | title (required), and body, labels (names), assignees (logins), milestone (number) |
| $repository = null | null | string | |
| returns | array | the new issue, number included |
createLabel($name, $color, $repository)
GitHubAPI.php:320createMilestone($title, $repository)
GitHubAPI.php:351DefaultConfig()
staticGitHubAPI.php:47| returns | array |
deleteComment($id, $repository)
GitHubAPI.php:306exec($path, $post, $method)
GitHubAPI.php:119Call an API endpoint.
get($path, $post, $method)
GitHubAPI.php:140Call an API endpoint and decode its JSON body.
getAll($path, $limit)
GitHubAPI.php:228Read a list endpoint page after page: GitHub answers 30 items per call unless asked, and 100 at most.
| $path | string | the path, with or without a query string |
| $limit = null | null | int | the number of items to read at most, null for every page |
| returns | array | the items of every page read, in order |
getAssignees($repository)
GitHubAPI.php:335getBranch($branch, $repository)
GitHubAPI.php:361getBranchHash($branch, $repository)
GitHubAPI.php:366getComment($id, $repository)
GitHubAPI.php:287getComments($number, $repository)
GitHubAPI.php:282getHeaders()
GitHubAPI.php:102| returns | array | the headers every call sends, including the token when one is configured. |
getIssue($number, $repository)
GitHubAPI.php:251getIssues($state, $repository, $limit)
GitHubAPI.php:245| $state = 'open' | string | open, closed or all |
| $repository = null | null | string | |
| $limit = null | null | int | the number of issues to read at most (the most recently created first), null for all |
| returns | array | the issues. GitHub includes pull requests here, so entries carrying a pull_request key are dropped -- getPullRequests lists those. They still count in $limit. |
getLabels($repository)
GitHubAPI.php:311getMilestones($state, $repository)
GitHubAPI.php:343getPullRequests($state, $repository)
GitHubAPI.php:217getRateLimit()
GitHubAPI.php:380| returns | array | the rate limit left for this client, as {limit, remaining, reset} -- worth checking before a loop of calls, because an exhausted limit answers 403 rather than 429. |
getReleases($repository)
GitHubAPI.php:356getRepository()
GitHubAPI.php:55getRepositoryInfo($repository)
GitHubAPI.php:209getTokenFingerprint()
GitHubAPI.php:78| returns | string | what tells this client's token from another one, without telling the token: two tokens may see different things (a private repository), so a cache of what GitHub answered keys on it |
getUser()
GitHubAPI.php:371| returns | array | the authenticated user, asked once. @throws eRuntime when no token is configured. |
graphql($query, $variables)
GitHubAPI.php:168Run a GraphQL query or mutation: what the REST API does not cover, GitHub Projects first of all. GraphQL always needs a token.
| $query | string | |
| $variables = [] | array | |
| returns | array | the answer's data |
| throws | when there is no token, or GitHub answered with errors (which it does with a 200) |
isAuthenticated()
GitHubAPI.php:70| returns | bool |
mutate($name, $input, $select)
GitHubAPI.php:189Run one GraphQL mutation, whose input type is named after it, as GitHub's all are.
| $name | string | e.g. addProjectV2DraftIssue |
| $input | array | |
| $select = 'clientMutationId' | string | what to read from its payload |
| returns | array | the payload |
RepositoryName($repo, $remote)
staticGitHubAPI.php:90Derive the owner/name of a repository from one of its remotes, so a local Repository can be matched to its GitHub project without repeating the name in the configuration.
| $repo | Repository | |
| $remote = '' | string | the remote to read, or '' for the first one |
| returns | null | string | null when no remote points at github.com |
setRepository($repository)
GitHubAPI.php:59setToken($token)
GitHubAPI.php:64updateComment($id, $body, $repository)
GitHubAPI.php:302updateIssue($number, $fields, $repository)
GitHubAPI.php:273Change an issue: only the fields given change. A label named here and unknown to the repository is created.
| $number | int | |
| $fields | array | as createIssue, plus state (open, closed) and state_reason (completed, not_planned, reopened); milestone null takes it out of its milestone |
| $repository = null | null | string | |
| returns | array | the issue as it is now |
updateLabel($name, $fields, $repository)
GitHubAPI.php:330| $name | string | the label's name now |
| $fields | array | new_name, color (rrggbb), description |
| $repository = null | null | string | |
| returns | array | the label, as it is now |
__wakeup()
GitHubAPI.php:51| returns | void |
Inherited members (47)
| Constants | Declared by | Description | |
|---|---|---|---|
ALERT | iLogLevel | Alert: Action must be taken immediately. | |
ALL | iLogLevel | Mask for all | |
ALL_PLUS | iLogLevel | debug everything | |
BACKTRACE | iLogLevel | ||
CRITICAL | iLogLevel | Critical: Critical conditions. | |
DEBUG | iLogLevel | Debug: Detailed debug information. | |
DEEP | iLogLevel | debug everything with arguments | |
EMERGENCY | iLogLevel | Emergency: System is unusable. | |
ERROR | iLogLevel | Error: Runtime errors that do not require immediate action but should typically be logged and monitored. | |
ERROR_PLUS | iLogLevel | Mask for all error | |
FATAL | iLogLevel | Mask for all fatal error | |
INFO | iLogLevel | Info: Interesting events. | |
INFO_PLUS | iLogLevel | Mask for all errors/warning/notices/info | |
MEMORY | iLogLevel | include backtrace object | |
NOTICE | iLogLevel | Notice: Normal but significant events. | |
NOTICE_PLUS | iLogLevel | Mask for all errors/warning/notices/info | |
TRACE | iLogLevel | include backtrace as origins | |
WARNING | iLogLevel | Warning: Exceptional occurrences that are not errors. | |
WARNING_PLUS | iLogLevel | Mask for all errors and warnings |
| Properties | Declared by | Description | |
|---|---|---|---|
verbosity | aModule |
| Methods | Declared by | Description | |
|---|---|---|---|
alert($message, $context) | aModule | Action must be taken immediately. | |
backtraces($message, $context) | aModule | Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it). | |
Configure($config) | aModule | Merge $config into this module's configuration in the shared Configuration. | |
critical($message, $context) | aModule | Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask. | |
debug($message, $context) | aModule | Detailed debug information. | |
debugName() | aModule | Human-readable identifier used as the default {origin} in this instance's log messages. | |
emergency($message, $context) | aModule | System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask. | |
error($message, $context) | aModule | Runtime errors that do not require immediate action but should typically be logged and monitored. | |
getVerbosity() | aModule | ||
info($message, $context) | aModule | Interesting events. No-op if INFO is currently filtered out by the verbosity mask. | |
Instantiate($config) | aModule | (Re)create the shared instance immediately, configured with $config merged into the class's existing config. | |
IsShared() | aModule | ||
log($level, $message, $context) | aModule | Logs with an arbitrary level. | |
notice($message, $context) | aModule | Normal but significant events. | |
offsetExists($key) | aModule | \ArrayAccess::offsetExists -- tells whether $key is a declared property at all, regardless of whether it is currently readable/writable through array access. | |
offsetGet($key) | aModule | \ArrayAccess::offsetGet -- reads a property directly, unless it has a #[Serialize(serialize: 'methodName')] attribute, in which case that zero-argument method is called instead (e.g. | |
offsetSet($key, $value) | aModule | \ArrayAccess::offsetSet -- sets a property directly, unless it has a #[Serialize(unserialize: 'methodName')] attribute, in which case that method is called with $value instead (e.g. | |
offsetUnset($key) | aModule | \ArrayAccess::offsetUnset -- equivalent to $module[$key] = null. | |
serialize($path, $serializer) | aModule | \MMO\core\interfaces\iSerializable::serialize -- exports every property (via | |
setVerbosity($verb) | aModule | Set the current verbosity mask, replacing whatever it was before. | |
Shared() | aModule | Get the shared instance, creating (and configuring) it on first call. | |
testVerbosity($level) | aModule | Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask. | |
traitUnshare($serialize) | aModule | Remove the shared instance, so the next Shared() call creates a fresh one. | |
unserialize($data, $path, $instances) | aModule | \MMO\core\interfaces\iSerializable::unserialize -- merges $data onto DefaultConfig, runs it through the (possibly overridden) constructor, then applies each resulting value to its property (via | |
Unshare($serialize) | aModule | Like tSingleton::Unshare, but also disconnects this module's instance from every event it was listening to (via Event::DisconnectListeners) before dropping it. | |
warning($message, $context) | aModule | Exceptional occurrences that are not errors. | |
__construct($config) | aModule | protected constructor, so it is not possible to do new Module(...) called by the serialization process just before being injected with data. |