Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Message.php

Zuletzt modifiziert: 09.10.2024, 12:55 - Dateigröße: 2.85 KiB


 001  <?php
 002  /**
 003   * Zend Framework (http://framework.zend.com/)
 004   *
 005   * @link      http://github.com/zendframework/zf2 for the canonical source repository
 006   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
 007   * @license   http://framework.zend.com/license/new-bsd New BSD License
 008   */
 009   
 010  namespace Zend\Stdlib;
 011   
 012  use Traversable;
 013   
 014  class Message implements MessageInterface
 015  {
 016      /**
 017       * @var array
 018       */
 019      protected $metadata = array();
 020   
 021      /**
 022       * @var string
 023       */
 024      protected $content = '';
 025   
 026      /**
 027       * Set message metadata
 028       *
 029       * Non-destructive setting of message metadata; always adds to the metadata, never overwrites
 030       * the entire metadata container.
 031       *
 032       * @param  string|int|array|Traversable $spec
 033       * @param  mixed $value
 034       * @throws Exception\InvalidArgumentException
 035       * @return Message
 036       */
 037      public function setMetadata($spec, $value = null)
 038      {
 039          if (is_scalar($spec)) {
 040              $this->metadata[$spec] = $value;
 041              return $this;
 042          }
 043          if (!is_array($spec) && !$spec instanceof Traversable) {
 044              throw new Exception\InvalidArgumentException(sprintf(
 045                  'Expected a string, array, or Traversable argument in first position; received "%s"',
 046                  (is_object($spec) ? get_class($spec) : gettype($spec))
 047              ));
 048          }
 049          foreach ($spec as $key => $value) {
 050              $this->metadata[$key] = $value;
 051          }
 052          return $this;
 053      }
 054   
 055      /**
 056       * Retrieve all metadata or a single metadatum as specified by key
 057       *
 058       * @param  null|string|int $key
 059       * @param  null|mixed $default
 060       * @throws Exception\InvalidArgumentException
 061       * @return mixed
 062       */
 063      public function getMetadata($key = null, $default = null)
 064      {
 065          if (null === $key) {
 066              return $this->metadata;
 067          }
 068   
 069          if (!is_scalar($key)) {
 070              throw new Exception\InvalidArgumentException('Non-scalar argument provided for key');
 071          }
 072   
 073          if (array_key_exists($key, $this->metadata)) {
 074              return $this->metadata[$key];
 075          }
 076   
 077          return $default;
 078      }
 079   
 080      /**
 081       * Set message content
 082       *
 083       * @param  mixed $value
 084       * @return Message
 085       */
 086      public function setContent($value)
 087      {
 088          $this->content = $value;
 089          return $this;
 090      }
 091   
 092      /**
 093       * Get message content
 094       *
 095       * @return mixed
 096       */
 097      public function getContent()
 098      {
 099          return $this->content;
 100      }
 101   
 102      /**
 103       * @return string
 104       */
 105      public function toString()
 106      {
 107          $request = '';
 108          foreach ($this->getMetadata() as $key => $value) {
 109              $request .= sprintf(
 110                  "%s: %s\r\n",
 111                  (string) $key,
 112                  (string) $value
 113              );
 114          }
 115          $request .= "\r\n" . $this->getContent();
 116          return $request;
 117      }
 118  }
 119