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

OutputFormatterStyleStack.php

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


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Component\Console\Formatter;
 013   
 014  use Symfony\Component\Console\Exception\InvalidArgumentException;
 015   
 016  /**
 017   * @author Jean-François Simon <contact@jfsimon.fr>
 018   */
 019  class OutputFormatterStyleStack
 020  {
 021      /**
 022       * @var OutputFormatterStyleInterface[]
 023       */
 024      private $styles;
 025   
 026      /**
 027       * @var OutputFormatterStyleInterface
 028       */
 029      private $emptyStyle;
 030   
 031      /**
 032       * Constructor.
 033       *
 034       * @param OutputFormatterStyleInterface|null $emptyStyle
 035       */
 036      public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
 037      {
 038          $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
 039          $this->reset();
 040      }
 041   
 042      /**
 043       * Resets stack (ie. empty internal arrays).
 044       */
 045      public function reset()
 046      {
 047          $this->styles = array();
 048      }
 049   
 050      /**
 051       * Pushes a style in the stack.
 052       *
 053       * @param OutputFormatterStyleInterface $style
 054       */
 055      public function push(OutputFormatterStyleInterface $style)
 056      {
 057          $this->styles[] = $style;
 058      }
 059   
 060      /**
 061       * Pops a style from the stack.
 062       *
 063       * @param OutputFormatterStyleInterface|null $style
 064       *
 065       * @return OutputFormatterStyleInterface
 066       *
 067       * @throws InvalidArgumentException When style tags incorrectly nested
 068       */
 069      public function pop(OutputFormatterStyleInterface $style = null)
 070      {
 071          if (empty($this->styles)) {
 072              return $this->emptyStyle;
 073          }
 074   
 075          if (null === $style) {
 076              return array_pop($this->styles);
 077          }
 078   
 079          foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
 080              if ($style->apply('') === $stackedStyle->apply('')) {
 081                  $this->styles = array_slice($this->styles, 0, $index);
 082   
 083                  return $stackedStyle;
 084              }
 085          }
 086   
 087          throw new InvalidArgumentException('Incorrectly nested style tag found.');
 088      }
 089   
 090      /**
 091       * Computes current style with stacks top codes.
 092       *
 093       * @return OutputFormatterStyle
 094       */
 095      public function getCurrent()
 096      {
 097          if (empty($this->styles)) {
 098              return $this->emptyStyle;
 099          }
 100   
 101          return $this->styles[count($this->styles) - 1];
 102      }
 103   
 104      /**
 105       * @param OutputFormatterStyleInterface $emptyStyle
 106       *
 107       * @return OutputFormatterStyleStack
 108       */
 109      public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
 110      {
 111          $this->emptyStyle = $emptyStyle;
 112   
 113          return $this;
 114      }
 115   
 116      /**
 117       * @return OutputFormatterStyleInterface
 118       */
 119      public function getEmptyStyle()
 120      {
 121          return $this->emptyStyle;
 122      }
 123  }
 124