home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Services / Ebay / Error.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.4 KB  |  130 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Stephan Schmidt <schst@php.net>                             |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Error.php,v 1.1 2005/06/05 13:35:59 schst Exp $
  20.  
  21. /**
  22.  * Services/Ebay/Error.php
  23.  *
  24.  * Warning object
  25.  *
  26.  * @package  Services_Ebay
  27.  * @author   Stephan Schmidt <schst@php.net>
  28.  */
  29.  
  30. /**
  31.  * Services_Ebay_Error
  32.  *
  33.  * Gives you access to an error returned by eBay
  34.  *
  35.  * @package  Services_Ebay
  36.  * @author   Stephan Schmidt <schst@php.net>
  37.  */
  38. class Services_Ebay_Error
  39. {
  40.     private $code = null;
  41.     private $severityCode = null;
  42.     private $severity = null;
  43.     private $shortMessage = null;
  44.     private $longMessage = null;
  45.  
  46.    /**
  47.     * create a new error object
  48.     *
  49.     * @param array      error data
  50.     */
  51.     public function __construct($data)
  52.     {
  53.         if (isset($data['Code'])) {
  54.             $this->code = (integer)$data['Code'];
  55.         }
  56.         if (isset($data['SeverityCode'])) {
  57.             $this->severityCode = (integer)$data['SeverityCode'];
  58.         }
  59.         if (isset($data['Severity'])) {
  60.             $this->severity = $data['Severity'];
  61.         }
  62.         if (isset($data['ShortMessage'])) {
  63.             $this->shortMessage = $data['ShortMessage'];
  64.         }
  65.         if (isset($data['LongMessage'])) {
  66.             $this->longMessage = $data['LongMessage'];
  67.         }
  68.     }
  69.     
  70.    /**
  71.     * return the error code
  72.     *
  73.     * @return int
  74.     */
  75.     public function getCode()
  76.     {
  77.         return $this->code;
  78.     }
  79.  
  80.    /**
  81.     * return the severity code
  82.     *
  83.     * @return int
  84.     */
  85.     public function getSeverityCode()
  86.     {
  87.         return $this->severityCode;
  88.     }
  89.  
  90.    /**
  91.     * return the severity as a string
  92.     *
  93.     * @return string
  94.     */
  95.     public function getSeverity()
  96.     {
  97.         return $this->severity;
  98.     }
  99.  
  100.    /**
  101.     * return the short message
  102.     *
  103.     * @return string
  104.     */
  105.     public function getShortMessage()
  106.     {
  107.         return $this->shortMessage;
  108.     }
  109.  
  110.    /**
  111.     * return the short message
  112.     *
  113.     * @return string
  114.     */
  115.     public function getLongMessage()
  116.     {
  117.         return $this->longMessage;
  118.     }
  119.     
  120.    /**
  121.     * String overloading
  122.     *
  123.     * @return string
  124.     */
  125.     public function __toString()
  126.     {
  127.         return sprintf("Services_Ebay %s: %s (%d)\n", $this->getSeverity(), $this->getLongMessage(), $this->getCode());
  128.     }
  129. }
  130. ?>