[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/zendframework/zend-code/src/Generator/ -> AbstractGenerator.php (source)

   1  <?php
   2  /**
   3   * Zend Framework (http://framework.zend.com/)
   4   *
   5   * @link      http://github.com/zendframework/zf2 for the canonical source repository
   6   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
   7   * @license   http://framework.zend.com/license/new-bsd New BSD License
   8   */
   9  
  10  namespace Zend\Code\Generator;
  11  
  12  use Traversable;
  13  
  14  abstract class AbstractGenerator implements GeneratorInterface
  15  {
  16      /**
  17       * Line feed to use in place of EOL
  18       */
  19      const LINE_FEED = "\n";
  20  
  21      /**
  22       * @var bool
  23       */
  24      protected $isSourceDirty = true;
  25  
  26      /**
  27       * @var int|string 4 spaces by default
  28       */
  29      protected $indentation = '    ';
  30  
  31      /**
  32       * @var string
  33       */
  34      protected $sourceContent = null;
  35  
  36      /**
  37       * @param  array $options
  38       */
  39      public function __construct($options = array())
  40      {
  41          if ($options) {
  42              $this->setOptions($options);
  43          }
  44      }
  45  
  46      /**
  47       * @param  bool $isSourceDirty
  48       * @return AbstractGenerator
  49       */
  50      public function setSourceDirty($isSourceDirty = true)
  51      {
  52          $this->isSourceDirty = (bool) $isSourceDirty;
  53          return $this;
  54      }
  55  
  56      /**
  57       * @return bool
  58       */
  59      public function isSourceDirty()
  60      {
  61          return $this->isSourceDirty;
  62      }
  63  
  64      /**
  65       * @param  string $indentation
  66       * @return AbstractGenerator
  67       */
  68      public function setIndentation($indentation)
  69      {
  70          $this->indentation = (string) $indentation;
  71          return $this;
  72      }
  73  
  74      /**
  75       * @return string
  76       */
  77      public function getIndentation()
  78      {
  79          return $this->indentation;
  80      }
  81  
  82      /**
  83       * @param  string $sourceContent
  84       * @return AbstractGenerator
  85       */
  86      public function setSourceContent($sourceContent)
  87      {
  88          $this->sourceContent = (string) $sourceContent;
  89          return $this;
  90      }
  91  
  92      /**
  93       * @return string
  94       */
  95      public function getSourceContent()
  96      {
  97          return $this->sourceContent;
  98      }
  99  
 100      /**
 101       * @param  array|Traversable $options
 102       * @throws Exception\InvalidArgumentException
 103       * @return AbstractGenerator
 104       */
 105      public function setOptions($options)
 106      {
 107          if (!is_array($options) && !$options instanceof Traversable) {
 108              throw new Exception\InvalidArgumentException(sprintf(
 109                  '%s expects an array or Traversable object; received "%s"',
 110                  __METHOD__,
 111                  (is_object($options) ? get_class($options) : gettype($options))
 112              ));
 113          }
 114  
 115          foreach ($options as $optionName => $optionValue) {
 116              $methodName = 'set' . $optionName;
 117              if (method_exists($this, $methodName)) {
 118                  $this->{$methodName}($optionValue);
 119              }
 120          }
 121  
 122          return $this;
 123      }
 124  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1