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) 2015 @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.2.0
 27:  */
 28: namespace Peach\Http\Header;
 29: 
 30: use Peach\Http\MultiHeaderField;
 31: use Peach\Util\ArrayMap;
 32: 
 33: /**
 34:  * Set-Cookie ヘッダーを表現するクラスです.
 35:  */
 36: class SetCookie implements MultiHeaderField
 37: {
 38:     /**
 39:      * 各 cookie のキーと, そのキーに相当する CookieItem オブジェクトをマッピングする ArrayMap です.
 40:      * 
 41:      * @var ArrayMap
 42:      */
 43:     private $items;
 44:     
 45:     /**
 46:      * 新しい SetCookie オブジェクトを構築します.
 47:      * 引数に cookie のキー, 値, 属性を指定することで, 初期化と同時に
 48:      * 1 個目の cookie を追加することができます.
 49:      * 引数を省略した場合は cookie を何も持たない状態で初期化されます.
 50:      * 
 51:      * @param string        $name    cookie のキー
 52:      * @param string        $value   cookie の値
 53:      * @param CookieOptions $options 各種属性
 54:      */
 55:     public function __construct($name = null, $value = null, CookieOptions $options = null)
 56:     {
 57:         $this->items = new ArrayMap();
 58:         if ($name !== null) {
 59:             $this->setItem($name, $value, $options);
 60:         }
 61:     }
 62:     
 63:     /**
 64:      * 指定されたキーと値の cookie を持つ新しい Set-Cookie ヘッダーを追加します.
 65:      * 
 66:      * @param string        $name    cookie のキー
 67:      * @param string        $value   cookie の値
 68:      * @param CookieOptions $options 各種属性
 69:      */
 70:     public function setItem($name, $value, CookieOptions $options = null)
 71:     {
 72:         $item = new CookieItem($name, $value, $options);
 73:         $this->items->put($name, $item);
 74:     }
 75:     
 76:     /**
 77:      * すべての Set-Cookie ヘッダーの値を配列で返します.
 78:      * 
 79:      * @return array すべての Set-Cookie ヘッダー値の配列
 80:      */
 81:     public function format()
 82:     {
 83:         $result = array();
 84:         foreach ($this->items as $item) {
 85:             $result[] = $item->format();
 86:         }
 87:         return $result;
 88:     }
 89:     
 90:     /**
 91:      * 文字列 "set-cookie" を返します.
 92:      * 
 93:      * @return string ヘッダー名 "set-cookie"
 94:      */
 95:     public function getName()
 96:     {
 97:         return "set-cookie";
 98:     }
 99:     
100:     /**
101:      * このオブジェクトにセットされている Set-Cookie ヘッダーの一覧を
102:      * CookieItem オブジェクトの配列として返します.
103:      * 
104:      * @return CookieItem[] CookieItem オブジェクトの配列
105:      */
106:     public function getValues()
107:     {
108:         return array_values($this->items->asArray());
109:     }
110: }
111: 
PEACH2 API documentation generated by ApiGen