[FormatInterface] Add page

LogMANOriginal 2016-11-05 19:06:15 +01:00
parent d728112999
commit 0aa514741e

59
FormatInterface.md Normal file

@ -0,0 +1,59 @@
The `FormatInterface`interface defines functions that need to be implemented by all formats:
* [setItems](#the-setitems-function)
* [display](#the-display-function)
* [stringify](#the-stringify-function)
Find a [template](#template) at the end of this file
#Functions
##The `setItems` function
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 [BridgeAbstract](BridgeAbstract#items).
```PHP
setItems(array $items): self
```
##The `display` function
The `display` function shows the contents to the user and must return the object instance.
```PHP
display(): self
```
##The `stringify` function
The `stringify` function returns the items received by [`setItems`](#the-setitem-function) as string.
```PHP
stringify(): string
```
#Template
This is a bare minimum template for a format:
```PHP
<?php
class MyTypeFormat implements FormatInterface {
public function setItems(array $items){
// Implement your code here!
return $this;
}
public function stringify(){
// Implement your code here
return '';
}
public function display(){
// Implement your code here
echo $this->stringify();
return $this;
}
}
// Imaginary empty line!
```