PageRenderTime 20ms CodeModel.GetById 17ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin/PBAPI/PBAPI/Response.php

https://bitbucket.org/chamilo/chamilo-ext-repo-photobucket-dev/
PHP | 75 lines | 19 code | 8 blank | 48 comment | 2 complexity | fd9e1ac773f6c37a86fd06e7ca82d168 MD5 | raw file
 1<?php
 2/**
 3 * Photobucket API 
 4 * Fluent interface for PHP5
 5 * Response parent class
 6 * 
 7 * @author jhart
 8 * @package PBAPI
 9 * 
10 * @copyright Copyright (c) 2008, Photobucket, Inc.
11 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
12 */
13
14/**
15 * Response parser parent class
16 *
17 * @package PBAPI
18 */
19abstract class PBAPI_Response
20{
21    
22    /**
23     * Result data
24     *
25     * @var array
26     */
27    protected $result_data = array();
28    
29    /**
30     * parameter holder
31     *
32     * @var array
33     */
34    protected $params = array();
35
36    /**
37     * Class constructor
38     *
39     * @param array $params
40     */
41    public function __construct($params = array())
42    {
43        $this->params = $params;
44    }
45
46    /**
47     * Parse response
48     *
49     * @param string $response_string string to parse
50     * @param bool $onlycontent only return content 'node'
51     * @return string
52     */
53    abstract public function parse($string, $onlycontent = false);
54
55    /**
56     * Detect an exception response and throw a code exception
57     *
58     * @param array $data parsed data from parser strategy
59     */
60    protected function detectException(array $data)
61    {
62        if ($data['status'] != 'OK')
63        {
64            throw new PBAPI_Exception_Response($data['message'], $data['code']);
65        }
66    }
67
68    /**
69     * Returns optimal format for given parser
70     *
71     * @return string
72     */
73    abstract public function getFormat();
74
75}