The FormatInterface
interface defines functions that need to be implemented by all formats:
Find a template at the end of this file
Functions
display
function
The The display
function shows the contents to the user and must return the object instance.
display(): self
stringify
function
The The stringify
function returns the items received by setItems
as string.
stringify(): string
setItems
function
The The setItems
function receives an array of items generated by the bridge and must return the object instance. Each item represents an entry in the feed. For more information refer to the collectData function.
setItems(array $items): self
getItems
function
The The getItems
function returns the items previously set by the setItems
function. If no items where set previously this function returns an error.
getItems(): array
setCharset
function
The The setCharset
function receives the character set value as string and returns the object instance.
setCharset(string): self
getCharset
function
The The getCharset
function returns the character set value.
getCharset(): string
setExtraInfos
function
The The setExtraInfos
function receives an array of elements with additional information to generate format outputs and must return the object instance.
setExtraInfos(array $infos): self
Currently supported information are:
Name | Description |
---|---|
name |
Defines the name as generated by the bridge |
uri |
Defines the URI of the feed as generated by the bridge |
getExtraInfos
function
The The getExtraInfos
function returns the information previously set via the setExtraInfos
function.
getExtraInfos(): array
getMimeType
function
The The getMimeType
function returns the expected MIME type of the format’s output.
getMimeType(): string
Template
This is a bare minimum template for a format:
<?php
class MyTypeFormat implements FormatInterface {
private $items;
private $charset;
private $extraInfos;
public function stringify(){
// Implement your code here
return ''; // Return items as string
}
public function display(){
// Implement your code here
echo $this->stringify();
return $this;
}
public function setItems(array $items){
$this->items = $items;
return $this;
}
public function getItems(){
return $this->items;
}
public function setCharset($charset){
$this->charset = $charset;
return $this;
}
public function getCharset(){
return $this->charset;
}
public function setExtraInfos(array $infos){
$this->extraInfos = $infos;
return $this;
}
public function getExtraInfos(){
return $this->extraInfos;
}
}
// Imaginary empty line!