Snuze  0.8.1
snuze\Interfaces\Jsonable Interface Reference
Inheritance diagram for snuze\Interfaces\Jsonable:

Public Member Functions

 toJson ()
 fromJson (string $json)

Detailed Description

Jsonable promises that implementers will have public toJson() and fromJson() methods to facilitate converting their objects to and from JSON strings.

When implemented properly, it should be possible to pass the return value of toJson() into fromJson() and get back a functionally identical object.

This file is part of Snuze, a PHP client for the Reddit API. Copyright 2019 Shaun Cummiskey Repository: Documentation:

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

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.

Member Function Documentation

◆ fromJson()

snuze\Interfaces\Jsonable::fromJson ( string  $json)

This method should accept a JSON-formatted string, use it to construct an object of the appropriate type, and return that object.

Accurate return type declaration isn't possible yet, so the implementer must take care to return the desired object type.

string$jsonWell-formed JSON representing enough significant properties to construct an object
Revisit this (&& overrides) once PHP 7.4 covariance is mainstream

Implemented in snuze\Reddit\Thing\Account\MyAccount, snuze\Reddit\Thing\Thing, snuze\Reddit\Listing\Listing, and snuze\Reddit\AccessToken.

◆ toJson()

snuze\Interfaces\Jsonable::toJson ( )

This method should return a JSON-formatted string that represents an array of the object's significant properties.

string A string containing well-formed JSON

Implemented in snuze\Reddit\Thing\Account\MyAccount, snuze\Reddit\Thing\Thing, snuze\Reddit\AccessToken, and snuze\Reddit\Listing\Listing.

The documentation for this interface was generated from the following file: