Stack2RSS 1.0
A simple web application that creates an RSS feed given an API route.

src/converter.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /// \file converter.php Contains the Converter base class.
00004 
00005 /// Converts JSON data to proper HTML response
00006 /**
00007  * Converter is an abstract base class that represents a conversion for a particular type of item returned by the API.
00008  */
00009 abstract class Converter
00010 {
00011     /// Performs the actual conversion
00012     /**
00013      * The data returned by this function is an array of objects that contain the following members:
00014      * - title
00015      * - description
00016      * - link
00017      * - date
00018      * \param[in] $json_array the JSON array contained in the API response
00019      * \return an array that contains the HTML for the items
00020      */
00021     public function PerformConversion($json_array)
00022     {
00023         // Contains the array of HTML items
00024         $output = array();
00025         
00026         foreach($json_array as $item)
00027         {
00028             $output[] = array('title'       => $this->GetTitle($item),
00029                               'description' => $this->GetDescription($item),
00030                               'link'        => $this->GetLink($item),
00031                               'date'        => $this->GetDate($item));
00032         }
00033         
00034         return $output;
00035     }
00036     
00037     /// Returns the title of the given item
00038     /**
00039      * \param[in] $json_item the JSON for the particular item
00040      * \return the HTML for the title of the item
00041      */
00042     abstract protected function GetTitle($json_item);
00043     
00044     /// Returns the description of the given item
00045     /**
00046      * \param[in] $json_item the JSON for the particular item
00047      * \return the HTML for the description of the item
00048      */
00049     abstract protected function GetDescription($json_item);
00050     
00051     /// Returns the link for the given item
00052     /**
00053      * \param[in] $json_item the JSON for the particular item
00054      * \return the link for the item
00055      */
00056     abstract protected function GetLink($json_item);
00057     
00058     /// Returns the date of the given item
00059     /**
00060      * \param[in] $json_item the JSON for the particular item
00061      * \return the date of the item
00062      */
00063     abstract protected function GetDate($json_item);
00064 }
00065 
00066 ?>
 All Classes Files Functions Enumerations