Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

FormatterHelper.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 2.72 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\Helper;
 013   
 014  use Symfony\Component\Console\Formatter\OutputFormatter;
 015   
 016  /**
 017   * The Formatter class provides helpers to format messages.
 018   *
 019   * @author Fabien Potencier <fabien@symfony.com>
 020   */
 021  class FormatterHelper extends Helper
 022  {
 023      /**
 024       * Formats a message within a section.
 025       *
 026       * @param string $section The section name
 027       * @param string $message The message
 028       * @param string $style   The style to apply to the section
 029       *
 030       * @return string The format section
 031       */
 032      public function formatSection($section, $message, $style = 'info')
 033      {
 034          return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
 035      }
 036   
 037      /**
 038       * Formats a message as a block of text.
 039       *
 040       * @param string|array $messages The message to write in the block
 041       * @param string       $style    The style to apply to the whole block
 042       * @param bool         $large    Whether to return a large block
 043       *
 044       * @return string The formatter message
 045       */
 046      public function formatBlock($messages, $style, $large = false)
 047      {
 048          if (!\is_array($messages)) {
 049              $messages = [$messages];
 050          }
 051   
 052          $len = 0;
 053          $lines = [];
 054          foreach ($messages as $message) {
 055              $message = OutputFormatter::escape($message);
 056              $lines[] = sprintf($large ? '  %s  ' : ' %s ', $message);
 057              $len = max(self::strlen($message) + ($large ? 4 : 2), $len);
 058          }
 059   
 060          $messages = $large ? [str_repeat(' ', $len)] : [];
 061          for ($i = 0; isset($lines[$i]); ++$i) {
 062              $messages[] = $lines[$i].str_repeat(' ', $len - self::strlen($lines[$i]));
 063          }
 064          if ($large) {
 065              $messages[] = str_repeat(' ', $len);
 066          }
 067   
 068          for ($i = 0; isset($messages[$i]); ++$i) {
 069              $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
 070          }
 071   
 072          return implode("\n", $messages);
 073      }
 074   
 075      /**
 076       * Truncates a message to the given length.
 077       *
 078       * @param string $message
 079       * @param int    $length
 080       * @param string $suffix
 081       *
 082       * @return string
 083       */
 084      public function truncate($message, $length, $suffix = '...')
 085      {
 086          $computedLength = $length - self::strlen($suffix);
 087   
 088          if ($computedLength > self::strlen($message)) {
 089              return $message;
 090          }
 091   
 092          return self::substr($message, 0, $length).$suffix;
 093      }
 094   
 095      /**
 096       * {@inheritdoc}
 097       */
 098      public function getName()
 099      {
 100          return 'formatter';
 101      }
 102  }
 103