Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
OutputFormatterStyleStack.php
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 /**
015 * @author Jean-François Simon <contact@jfsimon.fr>
016 */
017 class OutputFormatterStyleStack
018 {
019 /**
020 * @var OutputFormatterStyleInterface[]
021 */
022 private $styles;
023
024 /**
025 * @var OutputFormatterStyleInterface
026 */
027 private $emptyStyle;
028
029 /**
030 * Constructor.
031 *
032 * @param OutputFormatterStyleInterface|null $emptyStyle
033 */
034 public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
035 {
036 $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
037 $this->reset();
038 }
039
040 /**
041 * Resets stack (ie. empty internal arrays).
042 */
043 public function reset()
044 {
045 $this->styles = array();
046 }
047
048 /**
049 * Pushes a style in the stack.
050 *
051 * @param OutputFormatterStyleInterface $style
052 */
053 public function push(OutputFormatterStyleInterface $style)
054 {
055 $this->styles[] = $style;
056 }
057
058 /**
059 * Pops a style from the stack.
060 *
061 * @param OutputFormatterStyleInterface|null $style
062 *
063 * @return OutputFormatterStyleInterface
064 *
065 * @throws \InvalidArgumentException When style tags incorrectly nested
066 */
067 public function pop(OutputFormatterStyleInterface $style = null)
068 {
069 if (empty($this->styles)) {
070 return $this->emptyStyle;
071 }
072
073 if (null === $style) {
074 return array_pop($this->styles);
075 }
076
077 foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
078 if ($style->apply('') === $stackedStyle->apply('')) {
079 $this->styles = array_slice($this->styles, 0, $index);
080
081 return $stackedStyle;
082 }
083 }
084
085 throw new \InvalidArgumentException('Incorrectly nested style tag found.');
086 }
087
088 /**
089 * Computes current style with stacks top codes.
090 *
091 * @return OutputFormatterStyle
092 */
093 public function getCurrent()
094 {
095 if (empty($this->styles)) {
096 return $this->emptyStyle;
097 }
098
099 return $this->styles[count($this->styles)-1];
100 }
101
102 /**
103 * @param OutputFormatterStyleInterface $emptyStyle
104 *
105 * @return OutputFormatterStyleStack
106 */
107 public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
108 {
109 $this->emptyStyle = $emptyStyle;
110
111 return $this;
112 }
113
114 /**
115 * @return OutputFormatterStyleInterface
116 */
117 public function getEmptyStyle()
118 {
119 return $this->emptyStyle;
120 }
121 }
122