[ Index ]

MailPress 544

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

title

Body

[close]

/mp-includes/Swiftmailer/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 = array();
  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 = array();
  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: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1