[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/zendframework/zend-eventmanager/src/ -> ResponseCollection.php (source)

   1  <?php
   2  /**
   3   * Zend Framework (http://framework.zend.com/)
   4   *
   5   * @link      http://github.com/zendframework/zf2 for the canonical source repository
   6   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
   7   * @license   http://framework.zend.com/license/new-bsd New BSD License
   8   */
   9  
  10  namespace Zend\EventManager;
  11  
  12  use SplStack;
  13  
  14  /**
  15   * Collection of signal handler return values
  16   */
  17  class ResponseCollection extends SplStack
  18  {
  19      protected $stopped = false;
  20  
  21      /**
  22       * Did the last response provided trigger a short circuit of the stack?
  23       *
  24       * @return bool
  25       */
  26      public function stopped()
  27      {
  28          return $this->stopped;
  29      }
  30  
  31      /**
  32       * Mark the collection as stopped (or its opposite)
  33       *
  34       * @param  bool $flag
  35       * @return ResponseCollection
  36       */
  37      public function setStopped($flag)
  38      {
  39          $this->stopped = (bool) $flag;
  40          return $this;
  41      }
  42  
  43      /**
  44       * Convenient access to the first handler return value.
  45       *
  46       * @return mixed The first handler return value
  47       */
  48      public function first()
  49      {
  50          return parent::bottom();
  51      }
  52  
  53      /**
  54       * Convenient access to the last handler return value.
  55       *
  56       * If the collection is empty, returns null. Otherwise, returns value
  57       * returned by last handler.
  58       *
  59       * @return mixed The last handler return value
  60       */
  61      public function last()
  62      {
  63          if (count($this) === 0) {
  64              return;
  65          }
  66          return parent::top();
  67      }
  68  
  69      /**
  70       * Check if any of the responses match the given value.
  71       *
  72       * @param  mixed $value The value to look for among responses
  73       * @return bool
  74       */
  75      public function contains($value)
  76      {
  77          foreach ($this as $response) {
  78              if ($response === $value) {
  79                  return true;
  80              }
  81          }
  82          return false;
  83      }
  84  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1