[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/composer/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ -> ArrayLogger.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of SwiftMailer.
   5   * (c) 2004-2009 Chris Corbyn
   6   *
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  /**
  12   * Logs to an Array backend.
  13   *
  14   * @author Chris Corbyn
  15   */
  16  class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger
  17  {
  18      /**
  19       * The log contents.
  20       *
  21       * @var array
  22       */
  23      private $log = [];
  24  
  25      /**
  26       * Max size of the log.
  27       *
  28       * @var int
  29       */
  30      private $size = 0;
  31  
  32      /**
  33       * Create a new ArrayLogger with a maximum of $size entries.
  34       *
  35       * @var int
  36       */
  37      public function __construct($size = 50)
  38      {
  39          $this->size = $size;
  40      }
  41  
  42      /**
  43       * Add a log entry.
  44       *
  45       * @param string $entry
  46       */
  47      public function add($entry)
  48      {
  49          $this->log[] = $entry;
  50          while (count($this->log) > $this->size) {
  51              array_shift($this->log);
  52          }
  53      }
  54  
  55      /**
  56       * Clear the log contents.
  57       */
  58      public function clear()
  59      {
  60          $this->log = [];
  61      }
  62  
  63      /**
  64       * Get this log as a string.
  65       *
  66       * @return string
  67       */
  68      public function dump()
  69      {
  70          return implode(PHP_EOL, $this->log);
  71      }
  72  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1