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

BatchResults.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.20 KiB


 001  <?php
 002  namespace GuzzleHttp;
 003   
 004  /**
 005   * Represents the result of a batch operation. This result container is
 006   * iterable, countable, and you can can get a result by value using the
 007   * getResult function.
 008   *
 009   * Successful results are anything other than exceptions. Failure results are
 010   * exceptions.
 011   *
 012   * @package GuzzleHttp
 013   */
 014  class BatchResults implements \Countable, \IteratorAggregate, \ArrayAccess
 015  {
 016      private $hash;
 017   
 018      /**
 019       * @param \SplObjectStorage $hash Hash of key objects to result values.
 020       */
 021      public function __construct(\SplObjectStorage $hash)
 022      {
 023          $this->hash = $hash;
 024      }
 025   
 026      /**
 027       * Get the keys that are available on the batch result.
 028       *
 029       * @return array
 030       */
 031      public function getKeys()
 032      {
 033          return iterator_to_array($this->hash);
 034      }
 035   
 036      /**
 037       * Gets a result from the container for the given object. When getting
 038       * results for a batch of requests, provide the request object.
 039       *
 040       * @param object $forObject Object to retrieve the result for.
 041       *
 042       * @return mixed|null
 043       */
 044      public function getResult($forObject)
 045      {
 046          return isset($this->hash[$forObject]) ? $this->hash[$forObject] : null;
 047      }
 048   
 049      /**
 050       * Get an array of successful results.
 051       *
 052       * @return array
 053       */
 054      public function getSuccessful()
 055      {
 056          $results = [];
 057          foreach ($this->hash as $key) {
 058              if (!($this->hash[$key] instanceof \Exception)) {
 059                  $results[] = $this->hash[$key];
 060              }
 061          }
 062   
 063          return $results;
 064      }
 065   
 066      /**
 067       * Get an array of failed results.
 068       *
 069       * @return array
 070       */
 071      public function getFailures()
 072      {
 073          $results = [];
 074          foreach ($this->hash as $key) {
 075              if ($this->hash[$key] instanceof \Exception) {
 076                  $results[] = $this->hash[$key];
 077              }
 078          }
 079   
 080          return $results;
 081      }
 082   
 083      /**
 084       * Allows iteration over all batch result values.
 085       *
 086       * @return \ArrayIterator
 087       */
 088      public function getIterator()
 089      {
 090          $results = [];
 091          foreach ($this->hash as $key) {
 092              $results[] = $this->hash[$key];
 093          }
 094   
 095          return new \ArrayIterator($results);
 096      }
 097   
 098      /**
 099       * Counts the number of elements in the batch result.
 100       *
 101       * @return int
 102       */
 103      public function count()
 104      {
 105          return count($this->hash);
 106      }
 107   
 108      /**
 109       * Checks if the batch contains a specific numerical array index.
 110       *
 111       * @param int $key Index to access
 112       *
 113       * @return bool
 114       */
 115      public function offsetExists($key)
 116      {
 117          return $key < count($this->hash);
 118      }
 119   
 120      /**
 121       * Allows access of the batch using a numerical array index.
 122       *
 123       * @param int $key Index to access.
 124       *
 125       * @return mixed|null
 126       */
 127      public function offsetGet($key)
 128      {
 129          $i = -1;
 130          foreach ($this->hash as $obj) {
 131              if ($key === ++$i) {
 132                  return $this->hash[$obj];
 133              }
 134          }
 135   
 136          return null;
 137      }
 138   
 139      public function offsetUnset($key)
 140      {
 141          throw new \RuntimeException('Not implemented');
 142      }
 143   
 144      public function offsetSet($key, $value)
 145      {
 146          throw new \RuntimeException('Not implemented');
 147      }
 148  }
 149