Overview

Namespaces

  • Peach
    • DF
    • DT
    • Http
      • Body
      • Header
    • Markup
    • Util

Classes

  • Peach\DF\Base64Codec
  • Peach\DF\CodecChain
  • Peach\DF\JsonCodec
  • Peach\DF\SerializationCodec
  • Peach\DF\Utf8Codec
  • Peach\DT\AbstractTime
  • Peach\DT\Clock
  • Peach\DT\Date
  • Peach\DT\Datetime
  • Peach\DT\DefaultClock
  • Peach\DT\FixedClock
  • Peach\DT\FormatWrapper
  • Peach\DT\HttpDateFormat
  • Peach\DT\OffsetClock
  • Peach\DT\ShiftFormat
  • Peach\DT\SimpleFormat
  • Peach\DT\TimeEquator
  • Peach\DT\Timestamp
  • Peach\DT\TimeWrapper
  • Peach\DT\UnixTimeFormat
  • Peach\DT\Util
  • Peach\DT\W3cDatetimeFormat
  • Peach\Http\Body
  • Peach\Http\Body\CodecRenderer
  • Peach\Http\Body\StringRenderer
  • Peach\Http\DefaultEndpoint
  • Peach\Http\Header\CookieItem
  • Peach\Http\Header\CookieOptions
  • Peach\Http\Header\HttpDate
  • Peach\Http\Header\NoField
  • Peach\Http\Header\QualityValues
  • Peach\Http\Header\Raw
  • Peach\Http\Header\SetCookie
  • Peach\Http\Header\Status
  • Peach\Http\Request
  • Peach\Http\Response
  • Peach\Http\Util
  • Peach\Markup\AbstractHelper
  • Peach\Markup\AbstractRenderer
  • Peach\Markup\BaseHelper
  • Peach\Markup\BreakControlWrapper
  • Peach\Markup\Builder
  • Peach\Markup\Code
  • Peach\Markup\Comment
  • Peach\Markup\ContainerElement
  • Peach\Markup\Context
  • Peach\Markup\DebugBuilder
  • Peach\Markup\DebugContext
  • Peach\Markup\DefaultBreakControl
  • Peach\Markup\DefaultBuilder
  • Peach\Markup\DefaultContext
  • Peach\Markup\Element
  • Peach\Markup\EmptyElement
  • Peach\Markup\HelperObject
  • Peach\Markup\HtmlHelper
  • Peach\Markup\Indent
  • Peach\Markup\MinimalBreakControl
  • Peach\Markup\NameBreakControl
  • Peach\Markup\NameValidator
  • Peach\Markup\NodeList
  • Peach\Markup\None
  • Peach\Markup\SgmlRenderer
  • Peach\Markup\Text
  • Peach\Markup\XmlRenderer
  • Peach\Util\AbstractMapEntry
  • Peach\Util\ArrayMap
  • Peach\Util\ArrayMapEntry
  • Peach\Util\Arrays
  • Peach\Util\DefaultComparator
  • Peach\Util\DefaultEquator
  • Peach\Util\HashMap
  • Peach\Util\HashMapEntry
  • Peach\Util\Strings
  • Peach\Util\Values

Interfaces

  • Peach\DF\Codec
  • Peach\DT\Format
  • Peach\DT\Time
  • Peach\Http\BodyRenderer
  • Peach\Http\Endpoint
  • Peach\Http\HeaderField
  • Peach\Http\MultiHeaderField
  • Peach\Http\SingleHeaderField
  • Peach\Markup\BreakControl
  • Peach\Markup\Component
  • Peach\Markup\Container
  • Peach\Markup\Helper
  • Peach\Markup\Node
  • Peach\Markup\Renderer
  • Peach\Util\Comparable
  • Peach\Util\Comparator
  • Peach\Util\Equator
  • Peach\Util\Map
  • Peach\Util\MapEntry
  • Overview
  • Namespace
  • Class
  1: <?php
  2: /*
  3:  * Copyright (c) 2014 @trashtoy
  4:  * https://github.com/trashtoy/
  5:  * 
  6:  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  7:  * this software and associated documentation files (the "Software"), to deal in
  8:  * the Software without restriction, including without limitation the rights to use,
  9:  * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
 10:  * Software, and to permit persons to whom the Software is furnished to do so,
 11:  * subject to the following conditions:
 12:  * 
 13:  * The above copyright notice and this permission notice shall be included in all
 14:  * copies or substantial portions of the Software.
 15:  * 
 16:  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17:  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 18:  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 19:  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 20:  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 21:  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 22:  */
 23: /**
 24:  * PHP class file.
 25:  * @auhtor trashtoy
 26:  * @since  2.0.0
 27:  */
 28: namespace Peach\DT;
 29: use Peach\Util\ArrayMap;
 30: 
 31: /**
 32:  * 既存の時間オブジェクトを機能拡張するためのラッパークラスです.
 33:  * このクラスは Decorator パターンで設計されています.
 34:  */
 35: class TimeWrapper implements Time
 36: {
 37:     /**
 38:      * ラップする時間オブジェクトです.
 39:      * @var Time
 40:      */
 41:     private $original;
 42:     
 43:     /**
 44:      * 指定された時間オブジェクトをラップする TimeWrapper を構築します.
 45:      * 
 46:      * @param Time $original ラップ対象の時間オブジェクト
 47:      */
 48:     public function __construct(Time $original)
 49:     {
 50:         $this->original = $original;
 51:     }
 52:     
 53:     /**
 54:      * ラップ対象の時間オブジェクトを返します.
 55:      * @return Time
 56:      */
 57:     public function getOriginal()
 58:     {
 59:         return $this->original;
 60:     }
 61:     
 62:     /**
 63:      * ラップ対象のオブジェクトのタイプを返します.
 64:      * @return int
 65:      */
 66:     public function getType()
 67:     {
 68:         return $this->original->getType();
 69:     }
 70:     
 71:     /**
 72:      * ラップ対象のオブジェクトの before メソッドを実行します.
 73:      * @param  Time $time
 74:      * @return bool
 75:      */
 76:     public function before(Time $time)
 77:     {
 78:         return $this->original->before($time);
 79:     }
 80:     
 81:     /**
 82:      * ラップ対象のオブジェクトの after メソッドを実行します.
 83:      * @param  Time $time
 84:      * @return bool
 85:      */
 86:     public function after(Time $time)
 87:     {
 88:         return $this->original->after($time);
 89:     }
 90:     
 91:     /**
 92:      * ラップ対象のオブジェクトの compareTo メソッドを実行します.
 93:      * @param  Time $subject
 94:      * @return bool
 95:      */
 96:     public function compareTo($subject)
 97:     {
 98:         return $this->original->compareTo($subject);
 99:     }
100:     
101:     /**
102:      * 指定されたインスタンスをラップする新しい TimeWrapper を構築します.
103:      * 
104:      * @param  Time $instance ラップ対象のオブジェクト
105:      * @return TimeWrapper
106:      * @codeCoverageIgnore
107:      */
108:     protected function newInstance(Time $instance)
109:     {
110:         return new self($instance);
111:     }
112:     
113:     /**
114:      * ラップ対象のオブジェクトの add メソッドを実行し, その返り値をこのクラスでラップします.
115:      * 
116:      * @param  string $field
117:      * @param  int    $amount
118:      * @return TimeWrapper
119:      */
120:     public function add($field, $amount)
121:     {
122:         return $this->newInstance($this->original->add($field, $amount));
123:     }
124:     
125:     /**
126:      * ラップ対象のオブジェクトの set メソッドを実行し, その返り値をこのクラスでラップします.
127:      * 
128:      * @param  string $field
129:      * @param  int    $value
130:      * @return TimeWrapper
131:      */
132:     public function set($field, $value)
133:     {
134:         return $this->newInstance($this->original->set($field, $value));
135:     }
136:     
137:     /**
138:      * ラップ対象のオブジェクトの setAll メソッドを実行し, その返り値をこのクラスでラップします.
139:      * @param  array|ArrayMap $subject
140:      * @return TimeWrapper
141:      */
142:     public function setAll($subject)
143:     {
144:         return $this->newInstance($this->original->setAll($subject));
145:     }
146:     
147:     /**
148:      * ラップ対象のオブジェクトの get メソッドを実行します.
149:      * 
150:      * @param  string $field
151:      * @return int
152:      */
153:     public function get($field)
154:     {
155:         return $this->original->get($field);
156:     }
157:     
158:     /**
159:      * ラップ対象のオブジェクトの format メソッドを実行します.
160:      * @param  Format $format
161:      * @return string
162:      */
163:     public function format(Format $format = null)
164:     {
165:         return $this->original->format($format);
166:     }
167:     
168:     /**
169:      * ラップ対象のオブジェクトの formatTime メソッドを実行します.
170:      * @return string
171:      */
172:     public function formatTime()
173:     {
174:         return $this->original->formatTime();
175:     }
176:     
177:     /**
178:      * 指定されたオブジェクトとこのオブジェクトを比較します.
179:      * compareTo による比較結果が 0 を返し, かつクラスが同じ場合に TRUE を返します.
180:      *
181:      * @param  mixed   $obj 比較対象のオブジェクト
182:      * @return boolean      二つのオブジェクトが等しい場合に TRUE, それ以外は FALSE
183:      */
184:     public function equals($obj)
185:     {
186:         if (get_class($this) != get_class($obj)) {
187:             return false;
188:         }
189:         return $this->compareTo($obj) === 0;
190:     }
191:     
192:     /**
193:      * ラップ対象のオブジェクトの getDateCount メソッドを実行します.
194:      * @return int
195:      */
196:     public function getDateCount()
197:     {
198:         return $this->original->getDateCount();
199:     }
200:     
201:     /**
202:      * ラップ対象のオブジェクトの getDay メソッドを実行します.
203:      * @return int
204:      */
205:     public function getDay()
206:     {
207:         return $this->original->getDay();
208:     }
209:     
210:     /**
211:      * ラップ対象のオブジェクトの isLeapYear メソッドを実行します.
212:      * @return bool
213:      */
214:     public function isLeapYear()
215:     {
216:         return $this->original->isLeapYear();
217:     }
218:     
219:     /**
220:      * ラップ対象のオブジェクトの toDate メソッドを実行します.
221:      * @return Time
222:      */
223:     public function toDate()
224:     {
225:         return $this->original->toDate();
226:     }
227:     
228:     /**
229:      * ラップ対象のオブジェクトの toDatetime メソッドを実行します.
230:      * @return Time
231:      */
232:     public function toDatetime()
233:     {
234:         return $this->original->toDatetime();
235:     }
236:     
237:     /**
238:      * ラップ対象のオブジェクトの toTimestamp メソッドを実行します.
239:      * @return Time
240:      */
241:     public function toTimestamp()
242:     {
243:         return $this->original->toTimestamp();
244:     }
245:     
246:     /**
247:      * ラップ対象のオブジェクトの __toString メソッドを実行します.
248:      * @param  Time $time
249:      * @return string
250:      */
251:     public function __toString()
252:     {
253:         return $this->original->__toString();
254:     }
255: }
256: 
PEACH2 API documentation generated by ApiGen