Public Member Functions | |
__construct () | |
getAfter () | |
getBefore () | |
_getSourceJson () | |
add ($thing) | |
count () | |
getIterator () | |
toJson () | |
fromJson (string $json) | |
Public Member Functions inherited from snuze\SnuzeObject | |
__construct (array $args=null) | |
_getSnuzeId () | |
_getSnuzeClass () | |
_ident () | |
Protected Attributes | |
$children = [] | |
$_sourceJson = '' | |
Protected Attributes inherited from snuze\SnuzeObject | |
$_snuzeId = null | |
$_snuzeClass = null | |
Private Attributes | |
$after = null | |
$before = null | |
$modhash = null | |
Additional Inherited Members | |
Protected Member Functions inherited from snuze\SnuzeObject | |
debug (string $message, bool $echo=false) | |
info (string $message, bool $echo=false) | |
warning (string $message, bool $echo=false) | |
error (string $message, bool $echo=false) | |
A Listing represents a collection of Thing objects returned from the Reddit API in response to some request. It implements \IteratorAggregate and \Countable, so foreach() and count() can both be used directly on a Listing object.
A generic Listing can hold a heterogeneous mixture of all kinds of Things: Subreddits, Accounts, Comments, Messages, etc. For more strict collections, use a subtype: SubredditListing, LinkListing, CommentListing, etc.
This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey shaun @sha unc.c omhttps://shaunc.com/ Repository: https://github.com/snuze/snuze/ Documentation: https://snuze.shaunc.com/
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
snuze\Reddit\Listing\Listing::__construct | ( | ) |
Constructor.
snuze\Reddit\Listing\Listing::_getSourceJson | ( | ) |
Get the original JSON used to create this object via fromJson(), if applicable. This is intended for use by the test suite. You probably want toJson() instead!
snuze\Reddit\Listing\Listing::add | ( | $thing | ) |
Add a Thing to the collection. Accurate type hinting of the argument isn't possible yet, so it must be tested manually.
\snuze\Reddit\Thing\Thing | $thing | A Thing object to add to the collection |
snuze\Reddit\Listing\Listing::count | ( | ) |
snuze\Reddit\Listing\Listing::fromJson | ( | string | $json | ) |
Given the raw JSON response to any API request that returns a listing, attempt to create a Listing object whose $children array is full of Thing descendants.
string | $json | The raw JSON response from Reddit's API server |
Implements snuze\Interfaces\Jsonable.
References snuze\Reddit\Listing\Listing\add(), snuze\Reddit\Thing\Thing\KIND_ACCOUNT, snuze\Reddit\Thing\Thing\KIND_AWARD, snuze\Reddit\Thing\Thing\KIND_COMMENT, snuze\Reddit\Thing\Thing\KIND_LINK, snuze\Reddit\Thing\Thing\KIND_MESSAGE, and snuze\Reddit\Thing\Thing\KIND_SUBREDDIT.
snuze\Reddit\Listing\Listing::getAfter | ( | ) |
Get this listing's "after" specifier, if any. If a value is returned, it corresponds to the fullname of the last entity in the collection, and can be used for forward pagination.
snuze\Reddit\Listing\Listing::getBefore | ( | ) |
Get this listing's "before" specifier, if any. If a value is returned, it corresponds to the fullname of the first entity in the collection, and can be used for reverse pagination.
snuze\Reddit\Listing\Listing::getIterator | ( | ) |
Implement the \IteratorAggregate interface. This allows foreach() to be used productively on Listing objects
snuze\Reddit\Listing\Listing::toJson | ( | ) |
This method should return a JSON-formatted string that represents an array of the object's significant properties.
Implements snuze\Interfaces\Jsonable.
References snuze\Reddit\Listing\Listing\count().