This page will describe the Entity Abstract class. This class is the root of all Entity classes. Entity classes are used as containers for return values from various API endpoints. For example, the Article API will return an Article Entity, the Discussion API will return a Discussion Entity, and so on.
It is important to note that an API class will never return an Entity class directly. Rather, it will return an
Swader\Diffbot\Entity\EntityIterator, an iterable container with all the Entities inside. The container, however, is configured in such a way that executing get methods on it directly will forward those calls to the first Entity in its dataset. See
This class takes a single argument during construction, an array of data. This data is then turned into gettable information by means of getters, both direct and magic. Some getters do additional processing of the data in order to make it more useful to the user.
- $data (array) – The data
Returns the raw data passed into the Entity by the parent API class. This will be an associative array (see Usage below).
Usage:// ... $data = $article->getData(); echo $data['title']; echo $data['author']; // etc.
Magic method for resolving undefined getters and only getters. If the method being called starts with
get, the remainder of its name will be turned into a key to search inside the $data property (see
getData). Once the call is identified as a getter call,
__getis invoked (see below).
Returns: mixed Throws: BadMethodCallException if the prefix of the method is not
This method is called automatically when
__callis called. It looks for the property being asked for inside the
$dataproperty of the current class, or returns null if not found.
Usage:$api-> // ... set up API $myUrl = $api->buildUrl();