Overview

Namespaces

  • billythekid

Classes

  • PunkApi
  • Overview
  • Namespace
  • Class

Class PunkApi

Class PunkApi Wrapper class for querying the PunkAPI https://punkapi.com Docs: https://punkapi.com/documentation

Namespace: billythekid
Package: billythekid
Located at PunkApi.php
Methods summary
public
# __construct( $apiKey = 'v2' )

PunkApi constructor.

PunkApi constructor.

Parameters

$apiKey
public static billythekid\PunkApi
# create( $apiKey )

Static constructor, not really needed since PHP 5.4 but it's nice to have, right?

Static constructor, not really needed since PHP 5.4 but it's nice to have, right?

Parameters

$apiKey

Returns

billythekid\PunkApi
public string
# getEndpoint( )

Returns the URL that would be hit at the current state of this object.

Returns the URL that would be hit at the current state of this object.

Returns

string
public array
# getBeers( )

Queries the PunkAPI with the current parameters of this object.

Queries the PunkAPI with the current parameters of this object.

Returns

array
of beer \StdClass objects

Throws

InvalidArgumentException
(via GuzzleHttp\json_decode()
public
# clearParams( )

Empties the parameters of this object.

Empties the parameters of this object.

Returns


$this
public
# addParams( array $params )

Adds parameter options to this object.

Adds parameter options to this object.

Parameters

$params

Returns


$this
public
# removeParams( array $badParams )

Removes given parameters from this object.

Removes given parameters from this object.

Parameters

$badParams
$badParams

Returns


$this
public StdClass
# getRandomBeer( )

Get a random beer from the API

Get a random beer from the API

Returns

StdClass
beer object
public StdClass
# getBeerById( $beerId )

Get a beer from the API by it's ID number

Get a beer from the API by it's ID number

Returns

StdClass
beer object
public
# page( $pageNumber )

Set the parameters to return the given page of results

Set the parameters to return the given page of results

Parameters

$pageNumber

Returns


$this
public
# perPage( $number )

Set the number of beers to return per page

Set the number of beers to return per page

Parameters

$number

Returns


$this
public
# abvAbove( $number )

Sets the abv_gt parameter to the given number.

Sets the abv_gt parameter to the given number.

Parameters

$number

Returns


$this
public
# abvBelow( $number )

Sets the abv_lt parameter to the given number.

Sets the abv_lt parameter to the given number.

Parameters

$number

Returns


$this
public
# ibuAbove( $number )

Sets the ibu_gt parameter to the given number.

Sets the ibu_gt parameter to the given number.

Parameters

$number

Returns


$this
public
# ibuBelow( $number )

Sets the ibu_lt parameter to the given number.

Sets the ibu_lt parameter to the given number.

Parameters

$number

Returns


$this
public
# ebcAbove( $number )

Sets the ebc_gt parameter to the given number.

Sets the ebc_gt parameter to the given number.

Parameters

$number

Returns


$this
public
# ebcBelow( $number )

Sets the ebc_lt parameter to the given number.

Sets the ebc_lt parameter to the given number.

Parameters

$number

Returns


$this
public
# named( $beerName )

Sets the beer_name parameter to the given beer name.

Sets the beer_name parameter to the given beer name.

Parameters

$beerName

Returns


$this
public
# yeast( $yeastName )

Sets the yeast parameter to the given yeast name

Sets the yeast parameter to the given yeast name

Parameters

$yeastName

Returns


$this
public
# hops( $hopsName )

Sets the hops parameter to the given hops name

Sets the hops parameter to the given hops name

Parameters

$hopsName

Returns


$this
public
# malt( $maltName )

Sets the malt parameter to the given malt name

Sets the malt parameter to the given malt name

Parameters

$maltName

Returns


$this
public
# brewedBefore( $date )

Sets the brewed_before parameter to the given date

Sets the brewed_before parameter to the given date

Parameters

$date

Returns


$this
public
# brewedAfter( $date )

Sets the brewed_after parameter to the given date

Sets the brewed_after parameter to the given date

Parameters

$date

Returns


$this
public
# food( $foodName )

Sets the food parameter to the given food name

Sets the food parameter to the given food name

Parameters

$foodName

Returns


$this
public
# ids( mixed $ids )

Sets the ids paramater to the given ids

Sets the ids paramater to the given ids

Parameters

$ids
(array of ID numbers or piped string)

Returns


$this
API documentation generated by ApiGen