Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.
kherge edited this page Jul 25, 2012 · 3 revisions

The Amend helper retrieves a project repository's available downloads from GitHub (v3 API).

Table of Contents

getDownloads

<?php $list = $helper->getDownloads()

The getDownloads method returns the list of downloads (an array of download details arrays) found from the repository.

In addition the data returned by the GitHub API, a new key is added to each download item called version. The version entry contains an instance of KevinGH\Version\Version with the version that was extracted using the callable set by setExtractor.

getFile

<?php $path = $helper->getFile($download);

The getFile method downloads the file specified by $download to a temporary location and returns the file path.

The $download argument is one of entries in the array returned by the getDownloads method. Once the file has been downloaded, the callable set by setIntegrityChecker is called, and the file path passed to it. If the callable returns false, an exception will be thrown stating the download was corrupted.

getLatest

<?php $download = $helper->getLatest($lock);

The getLatest method returns the most recent version of the relevant download contained in the list returned by getDownloads.

By default, the download returned is within the same major version. If true is passed as $lock, newer major versions will be return instead, if they are available.

getVersion

<?php $version = $helper->getVersion();

The getVersion method returns the KevinGH\Version\Version instance set by setVersion.

setExtractor

<?php $helper->setExtractor($callable);

The setExtractor method sets the callable used to extract version numbers from download items.

When the $callable is used, the download item (an array of download details) is passed to $callable. A string is expected which will then be parsed by the KevinGH\Version\Version class.

setIntegrityChecker

<?php $helper->setIntegrityChecker($callable);

The setIntegrityChecker sets the callable used to verify the integrity of a downloaded file.

The $callable is passed the temporary file path of a downloaded item. If the download is corrupted, or unacceptable for any reason, false is expected to be returned. The callable may, however, thrown an exception to provide more detail about why a download is unacceptable or corrupt.

setLock

setMatcher

Clone this wiki locally