1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5/**
6 * Response framework for Digg API
7 *
8 * PHP version 5.1.0+
9 *
10 * LICENSE: This source file is subject to version 3.0 of the PHP license
11 * that is available through the world-wide-web at the following URI:
12 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
13 * the PHP License and are unable to obtain it through the web, please
14 * send a note to license@php.net so we can mail you a copy immediately.
15 *
16 * @category    Services
17 * @package     Services_Digg
18 * @author      Joe Stump <joe@joestump.net>
19 * @copyright   1997-2007 The PHP Group
20 * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
21 * @version     CVS: $Id:$
22 * @link        http://pear.php.net/package/Services_Digg
23 */
24
25require_once 'Services/Digg/Response/Exception.php';
26
27/**
28 * Services_Digg
29 *
30 * @category    Services
31 * @package     Services_Digg
32 * @author      Joe Stump <joe@joestump.net>
33 * @abstract
34 */
35abstract class Services_Digg_Response
36{
37    /**
38     * Create a response instance
39     *
40     * @access      public
41     * @param       string      $type       Type of response to create
42     * @param       string      $response   Raw response from API
43     * @throws      Services_Digg_Exception
44     */
45    static public function factory($type, $response) {
46        $file = 'Services/Digg/Response/' . $type . '.php';
47        if (!include_once($file)) {
48            throw new Services_Digg_Response_Exception('Unable to load response file: ' . $type);
49        }
50
51        $class = 'Services_Digg_Response_' . $type;
52        if (!class_exists($class)) {
53            throw new Services_Digg_Response_Exception('Unable to find response class: ' . $class);
54        }
55
56        $instance = new $class($response);
57        return $instance;
58    }
59}
60
61?>
62