Properties

$data

$data : \stdClass

Type

\stdClass — The branch's data.

$loaded

$loaded : boolean

Type

boolean — Has the full data for this branch been loaded or not.

$url

$url : string

Type

string — The endpoint to get the full branch data from.

Methods

request()

request(\duncan3dc\GitHub\string  $method, \duncan3dc\GitHub\string  $url, array  $data = array()) 

Parameters

\duncan3dc\GitHub\string $method
\duncan3dc\GitHub\string $url
array $data

post()

post(string  $url, array  $data = array()) : \stdClass

Send a POST request and return the response.

Parameters

string $url

The url to issue the request to

array $data

The parameters to send with the request

Returns

\stdClass

put()

put(string  $url, array  $data = array()) : \stdClass

Send a PUT request and return the response.

Parameters

string $url

The url to issue the request to

array $data

The parameters to send with the request

Returns

\stdClass

delete()

delete(string  $url, array  $data = array()) : \stdClass

Send a DELETE request and return the response.

Parameters

string $url

The url to issue the request to

array $data

The parameters to send with the request

Returns

\stdClass

get()

get(string  $url, array  $data = array()) : \stdClass

Send a GET request and return the response.

Parameters

string $url

The url to issue the request to

array $data

The parameters to send with the request

Returns

\stdClass

getAll()

getAll(string  $url, array  $data = array(), callable  $callback = null) : \Traversable|array<mixed,\stdClass>

Send a GET request and return the response.

This method will loop through all the pages until one returns no results

Parameters

string $url

The url to issue the request to

array $data

The parameters to send with the request

callable $callback

An optional handler to yield items via

Returns

\Traversable|array<mixed,\stdClass>

fromApiResponse()

fromApiResponse(\stdClass  $data, \duncan3dc\GitHub\ApiInterface  $api) : \duncan3dc\GitHub\BranchInterface

Create a new instance from an API request for the full branch data.

Parameters

\stdClass $data

The branch's data from the GitHub Api

\duncan3dc\GitHub\ApiInterface $api

The Api instance to communicate with GitHub

Returns

\duncan3dc\GitHub\BranchInterface

fromListResponse()

fromListResponse(\stdClass  $data, string  $url, \duncan3dc\GitHub\ApiInterface  $api) : \duncan3dc\GitHub\BranchInterface

Create a new instance from an API request for a list of branches.

Parameters

\stdClass $data

The branch's basic data from the GitHub Api

string $url

The endpoint to get the full branch data from

\duncan3dc\GitHub\ApiInterface $api

The Api instance to communicate with GitHub

Returns

\duncan3dc\GitHub\BranchInterface

getName()

getName() : string

Get the name of this branch.

Returns

string

getCommit()

getCommit() : string

Get the hash of the commit at the HEAD of the branch.

Returns

string

getHead()

getHead() : \stdClass

Get the details for the HEAD of a branch.

Returns

\stdClass

getDate()

getDate() : integer

Get the date this branch was last changed.

Returns

integer —

A unix timestamp

getProtection()

getProtection() : \stdClass

Get the protection details.

Returns

\stdClass

getDirectories()

getDirectories() 

getDirectory()

getDirectory(\duncan3dc\GitHub\string  $name) 

Parameters

\duncan3dc\GitHub\string $name

hasDirectory()

hasDirectory(\duncan3dc\GitHub\string  $name) 

Parameters

\duncan3dc\GitHub\string $name

getFiles()

getFiles() 

getFile()

getFile(\duncan3dc\GitHub\string  $name) 

Parameters

\duncan3dc\GitHub\string $name

hasFile()

hasFile(\duncan3dc\GitHub\string  $name) 

Parameters

\duncan3dc\GitHub\string $name

response()

response(\Psr\Http\Message\ResponseInterface  $response) : \stdClass

Convert a response into a simple object.

Parameters

\Psr\Http\Message\ResponseInterface $response

The response to convert

Returns

\stdClass

__construct()

__construct(\stdClass  $data, \duncan3dc\GitHub\ApiInterface  $api) 

Create a new instance.

Parameters

\stdClass $data

The branch's data from the GitHub Api

\duncan3dc\GitHub\ApiInterface $api

The Api instance to communicate with GitHub

getData()

getData() : \stdClass

Lazy load the full data for this branch.

Returns

\stdClass

getUrl()

getUrl(string  $path) : string

Generate a url using this branch as the base.

Parameters

string $path

The path underneath this branch to hit

Returns

string

getTree()

getTree() : \duncan3dc\GitHub\TreeInterface

Get a Tree instance that represents the root of the branch.

Returns

\duncan3dc\GitHub\TreeInterface