Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • Composer
  • Time
  • Util

Exceptions

  • ComposerException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * Jyxo PHP Library
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file license.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * https://github.com/jyxo/php/blob/master/license.txt
 12:  */
 13: 
 14: namespace Jyxo\Time;
 15: 
 16: /**
 17:  * Exception used by the \Jyxo\Time\Composer.
 18:  *
 19:  * Stores information which unit was incorrectly provided.
 20:  *
 21:  * @category Jyxo
 22:  * @package Jyxo\Time
 23:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
 24:  * @license https://github.com/jyxo/php/blob/master/license.txt
 25:  * @author Martin Šamšula
 26:  */
 27: class ComposerException extends \Jyxo\Exception
 28: {
 29:     /**
 30:      * Exception type - second.
 31:      *
 32:      * @var integer
 33:      */
 34:     const SECOND = 1;
 35: 
 36:     /**
 37:      * Exception type - minute.
 38:      *
 39:      * @var integer
 40:      */
 41:     const MINUTE = 2;
 42: 
 43:     /**
 44:      * Exception type - hour.
 45:      *
 46:      * @var integer
 47:      */
 48:     const HOUR = 3;
 49: 
 50:     /**
 51:      * Exception type - day.
 52:      *
 53:      * @var integer
 54:      */
 55:     const DAY = 4;
 56: 
 57:     /**
 58:      * Exception type - month.
 59:      *
 60:      * @var integer
 61:      */
 62:     const MONTH = 5;
 63: 
 64:     /**
 65:      * Exception type - year.
 66:      *
 67:      * @var integer
 68:      */
 69:     const YEAR = 6;
 70: 
 71:     /**
 72:      * Exception type - incomplete date.
 73:      *
 74:      * @var integer
 75:      */
 76:     const NOT_COMPLETE = 7;
 77: 
 78:     /**
 79:      * Exception type - invalid date.
 80:      *
 81:      * @var integer
 82:      */
 83:     const INVALID = 8;
 84: 
 85:     /**
 86:      * Exception type - unknown.
 87:      *
 88:      * @var integer
 89:      */
 90:     const UNKNOWN = 0;
 91: 
 92:     /**
 93:      * Constructor.
 94:      *
 95:      * @param string $message Exception message
 96:      * @param integer $code Exception code (type)
 97:      */
 98:     public function __construct($message, $code)
 99:     {
100:         static $allowedUnits = array(
101:             self::SECOND,
102:             self::MINUTE,
103:             self::HOUR,
104:             self::DAY,
105:             self::MONTH,
106:             self::YEAR,
107:             self::INVALID,
108:             self::NOT_COMPLETE
109:         );
110: 
111:         if (!in_array($code, $allowedUnits)) {
112:             $code = self::UNKNOWN;
113:         }
114: 
115:         parent::__construct($message, $code);
116:     }
117: }
118: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0