Public Member Functions | |
__construct (string $kind) | |
_getSourceJson () | |
getId () | |
getKind () | |
getCreated () | |
getCreatedUtc () | |
getFullname () | |
toJson () | |
fromJson (string $json) | |
Public Member Functions inherited from snuze\SnuzeObject | |
__construct (array $args=null) | |
_getSnuzeId () | |
_getSnuzeClass () | |
_ident () | |
Static Public Member Functions | |
static | getValidKinds () |
Public Attributes | |
const | KIND_COMMENT = 't1' |
const | KIND_ACCOUNT = 't2' |
const | KIND_LINK = 't3' |
const | KIND_MESSAGE = 't4' |
const | KIND_SUBREDDIT = 't5' |
const | KIND_AWARD = 't6' |
const | REGEX_VALID_ID = '|^[a-z0-9]{1,13}$|i' |
Protected Member Functions | |
setId (string $id) | |
setKind (string $kind) | |
setCreated (float $created) | |
setCreatedUtc (float $createdUtc) | |
getPropertyTranslationMap () | |
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) | |
Protected Attributes | |
$_kind = null | |
$_propertyNames = [] | |
$_propertyTranslationRegex = '|([a-z])([A-Z0-9])|' | |
$_sourceJson = '' | |
$id = null | |
$created = 0.0 | |
$createdUtc = 0.0 | |
Protected Attributes inherited from snuze\SnuzeObject | |
$_snuzeId = null | |
$_snuzeClass = null | |
The Thing class represents the common properties of all Reddit "things." Various subtypes of Thing exist to define the properties specific to those objects.
You can't instantiate a generic Thing object; instead, you should create and use the various subtypes: Subreddit, Link, Account, Comment, 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\Thing\Thing::_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\Thing\Thing::fromJson | ( | string | $json | ) |
Accepts a JSON-formatted string, uses it to build a Thing object, and returns that object. This satisfies a promise made in the Jsonable interface.
string | $json |
Implements snuze\Interfaces\Jsonable.
References snuze\Reddit\Thing\Thing\getPropertyTranslationMap().
snuze\Reddit\Thing\Thing::getCreated | ( | ) |
Get the epoch time this Thing was created. Reddit provides this as a float value, but the fractional part is always zero.
snuze\Reddit\Thing\Thing::getCreatedUtc | ( | ) |
Get the UTC epoch time this Thing was created. Reddit provides this as a float value, but the fractional part is always zero.
snuze\Reddit\Thing\Thing::getFullname | ( | ) |
snuze\Reddit\Thing\Thing::getId | ( | ) |
Get the Reddit internal identifier for this object.
|
protected |
Return an array whose keys are the class's camelCase property names, and whose values are the corresponding under_score names from Reddit's JSON. This map is used by the toJson() and fromJson() methods. This is mildly more convenient than manually mapping property names in each child class.
All Thing children must set their own $this->_propertyNames variable in their constructor.
|
static |
|
protected |
|
protected |
|
protected |
Set the Reddit internal identifier for this object.
string | $id |
snuze\Reddit\Thing\Thing::toJson | ( | ) |
Returns a JSON-formatted string representing this Thing's properties. Ideally, this should match Reddit's own data structure for returning "things" from the API.
Implements snuze\Interfaces\Jsonable.
References snuze\Reddit\Thing\Thing\getPropertyTranslationMap().
const snuze\Reddit\Thing\Thing::KIND_ACCOUNT = 't2' |
Defines the kind discriminator for an account
const snuze\Reddit\Thing\Thing::KIND_AWARD = 't6' |
Defines the kind discriminator for an award
const snuze\Reddit\Thing\Thing::KIND_COMMENT = 't1' |
Defines the kind discriminator for a comment
const snuze\Reddit\Thing\Thing::KIND_LINK = 't3' |
Defines the kind discriminator for a link (story, submission)
const snuze\Reddit\Thing\Thing::KIND_MESSAGE = 't4' |
Defines the kind discriminator for a message (direct message, modmail)
const snuze\Reddit\Thing\Thing::KIND_SUBREDDIT = 't5' |
Defines the kind discriminator for a subreddit
const snuze\Reddit\Thing\Thing::REGEX_VALID_ID = '|^[a-z0-9]{1,13}$|i' |
Defines a valid Thing ID. This is the base36 ID only, without the t1, t2, t3, etc. "kind" prefix.