Fluent
in package
Class Fluent
Table of Contents
- $typesWithoutJsonApi : array<string|int, string>
- $additional_headers : array<string|int, mixed>
- $client : Client
- $includes : array<string|int, mixed>
- $method : string
- $methods : array<string|int, mixed>
- $methodsRequiringAuthorization : array<string|int, mixed>
- $pagination : array<string|int, mixed>
- $query : array<string|int, mixed>
- $segments : array<string|int, mixed>
- $types : array<string|int, mixed>
- $variables : array<string|int, mixed>
- __call() : Fluent|void|mixed
- __construct() : mixed
- __toString() : string
- Returns request path
- addQueryParameter() : $this
- Add query parameters to the request
- delete() :
- discussions() :
- filter() : Fluent
- Add a filter to the current GET request
- get() :
- getHeaders() : array<string|int, mixed>
- getMethod() : string
- getType() : string
- getVariables() : array<string|int, mixed>
- groups() :
- head() :
- header() : $this
- Add additional headers
- id() : $this
- Add resource ID.
- include() : $this
- Add include query parameter to the request
- notifications() :
- offset() : Fluent
- Set the page offset of the current GET request
- page() :
- patch() :
- post() :
- posts() :
- put() :
- request() :
- reset() : $this
- Resets request data (segments (path), includes, query parameters, variables (json body), method)
- setMethod() : Fluent
- Set a request method
- setPath() : $this
- Set API endpoint (for non-regular requests)
- setVariables() : $this
- Set request variables (json body)
- tags() :
- token() :
- users() :
- handleType() : $this
- Handle request type
Properties
$typesWithoutJsonApi
public
array<string|int, string>
$typesWithoutJsonApi
= ['token']
$additional_headers
protected
array<string|int, mixed>
$additional_headers
= []
$client
protected
Client
$client
$includes
protected
array<string|int, mixed>
$includes
= []
$method
protected
string
$method
= 'get'
$methods
protected
array<string|int, mixed>
$methods
= ['get', 'head', 'post', 'put', 'patch', 'delete']
$methodsRequiringAuthorization
protected
array<string|int, mixed>
$methodsRequiringAuthorization
= ['post', 'put', 'patch', 'delete']
$pagination
protected
array<string|int, mixed>
$pagination
= ['page']
$query
protected
array<string|int, mixed>
$query
= []
$segments
protected
array<string|int, mixed>
$segments
= []
$types
protected
array<string|int, mixed>
$types
= ['token', 'discussions', 'posts', 'users', 'groups', 'notifications', 'tags']
$variables
protected
array<string|int, mixed>
$variables
= []
Methods
__call()
public
__call(string $name, mixed $arguments) : Fluent|void|mixed
Parameters
- $name : string
- $arguments : mixed
Tags
Return values
Fluent|void|mixed —__construct()
public
__construct(Client $flarum) : mixed
Parameters
- $flarum : Client
Return values
mixed —__toString()
Returns request path
public
__toString() : string
Return values
string —addQueryParameter()
Add query parameters to the request
public
addQueryParameter(string $type, mixed $value) : $this
Parameters
- $type : string
-
Query parameter key
- $value : mixed
-
Query parameter value
Tags
Return values
$this —delete()
public
delete() :
Set the DELETE request method and optionally send a JSON body, written as an array
Return values
—discussions()
public
discussions(int|null $id = null) :
Set the discussions endpoint and optionally filter the results providing a discussion ID
Parameters
- $id = null : int|null
Return values
—filter()
Add a filter to the current GET request
public
filter([array<string|int, mixed> $filters = [] ]) : Fluent
Parameters
- $filters : array<string|int, mixed> = []
Return values
Fluent —get()
public
get() :
Set the GET request method
Return values
—getHeaders()
public
getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —getMethod()
public
getMethod() : string
Return values
string —getType()
public
getType() : string
Return values
string —getVariables()
public
getVariables() : array<string|int, mixed>
Return values
array<string|int, mixed> —groups()
public
groups(int|null $id = null) :
Set the groups endpoint and optionally filter the results providing a group ID
Parameters
- $id = null : int|null
Return values
—head()
public
head() :
Set the HEAD request method
Return values
—header()
Add additional headers
public
header(array<string|int, mixed> $headers) : $this
Parameters
- $headers : array<string|int, mixed>
Return values
$this —id()
Add resource ID.
public
id(string|int $id) : $this
Parameters
- $id : string|int
Tags
Return values
$this —include()
Add include query parameter to the request
public
include(string $include) : $this
Parameters
- $include : string
Return values
$this —notifications()
public
notifications(int|null $id = null) :
Set the notifications endpoint. Only pass the notification ID if you are using the PATCH method
Parameters
- $id = null : int|null
Return values
—offset()
Set the page offset of the current GET request
public
offset(int $number) : Fluent
Parameters
- $number : int
Return values
Fluent —page()
public
page(int $page = 0) :
Set the page to request in the current GET request
Parameters
- $page = 0 : int
Return values
—patch()
public
patch(array<string|int, mixed> $variables = []) :
Set the PATCH request method and optionally send a JSON body, written as an array
Parameters
- $variables = [] : array<string|int, mixed>
Return values
—post()
public
post(array<string|int, mixed> $variables = []) :
Set the POST request method and optionally send a JSON body, written as an array
Parameters
- $variables = [] : array<string|int, mixed>
Return values
—posts()
public
posts(int|null $id = null) :
Set the posts endpoint and optionally filter the results providing a discussion ID
Parameters
- $id = null : int|null
Return values
—put()
public
put(array<string|int, mixed> $variables = []) :
Set the PUT request method and optionally send a JSON body, written as an array
Parameters
- $variables = [] : array<string|int, mixed>
Return values
—request()
public
request() :
Execute the request. If called without any endpoint and / or methods ( or GET), it returns Flarum info
Return values
—reset()
Resets request data (segments (path), includes, query parameters, variables (json body), method)
public
reset() : $this
Return values
$this —setMethod()
Set a request method
public
setMethod(string $method) : Fluent
Parameters
- $method : string
Tags
Return values
Fluent —setPath()
Set API endpoint (for non-regular requests)
public
setPath(string $path) : $this
Parameters
- $path : string
Return values
$this —setVariables()
Set request variables (json body)
public
setVariables([array<string|int, mixed> $variables = [] ]) : $this
Parameters
- $variables : array<string|int, mixed> = []
Return values
$this —tags()
public
tags(int|null $id = null) :
Set the tags endpoint and optionally filter the results providing a tag ID
Parameters
- $id = null : int|null
Return values
—token()
public
token() :
Set the token endpoint
Return values
—users()
public
users(string|int|null $id = null) :
Set the users endpoint and optionally filter the results providing a user ID or username
Parameters
- $id = null : string|int|null
Return values
—handleType()
Handle request type
protected
handleType(string $type, string|int $id) : $this
Parameters
- $type : string
- $id : string|int
-
If $type is user and ID is a string, it will be used as username. To use an ID, use an int