[ Index ] |
PHP Cross Reference of phpBB-3.3.10-deutsch |
[Summary view] [Print] [Text view]
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-2016 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 use function get_class; 15 use function gettype; 16 use function is_array; 17 use function is_object; 18 use function method_exists; 19 use function sprintf; 20 21 abstract class AbstractGenerator implements GeneratorInterface 22 { 23 /** 24 * Line feed to use in place of EOL 25 */ 26 const LINE_FEED = "\n"; 27 28 /** 29 * @var bool 30 */ 31 protected $isSourceDirty = true; 32 33 /** 34 * @var int|string 4 spaces by default 35 */ 36 protected $indentation = ' '; 37 38 /** 39 * @var string 40 */ 41 protected $sourceContent; 42 43 /** 44 * @param array $options 45 */ 46 public function __construct($options = []) 47 { 48 if ($options) { 49 $this->setOptions($options); 50 } 51 } 52 53 /** 54 * @param bool $isSourceDirty 55 * @return AbstractGenerator 56 */ 57 public function setSourceDirty($isSourceDirty = true) 58 { 59 $this->isSourceDirty = (bool) $isSourceDirty; 60 return $this; 61 } 62 63 /** 64 * @return bool 65 */ 66 public function isSourceDirty() 67 { 68 return $this->isSourceDirty; 69 } 70 71 /** 72 * @param string $indentation 73 * @return AbstractGenerator 74 */ 75 public function setIndentation($indentation) 76 { 77 $this->indentation = (string) $indentation; 78 return $this; 79 } 80 81 /** 82 * @return string 83 */ 84 public function getIndentation() 85 { 86 return $this->indentation; 87 } 88 89 /** 90 * @param string $sourceContent 91 * @return AbstractGenerator 92 */ 93 public function setSourceContent($sourceContent) 94 { 95 $this->sourceContent = (string) $sourceContent; 96 return $this; 97 } 98 99 /** 100 * @return string 101 */ 102 public function getSourceContent() 103 { 104 return $this->sourceContent; 105 } 106 107 /** 108 * @param array|Traversable $options 109 * @throws Exception\InvalidArgumentException 110 * @return AbstractGenerator 111 */ 112 public function setOptions($options) 113 { 114 if (! is_array($options) && ! $options instanceof Traversable) { 115 throw new Exception\InvalidArgumentException(sprintf( 116 '%s expects an array or Traversable object; received "%s"', 117 __METHOD__, 118 is_object($options) ? get_class($options) : gettype($options) 119 )); 120 } 121 122 foreach ($options as $optionName => $optionValue) { 123 $methodName = 'set' . $optionName; 124 if (method_exists($this, $methodName)) { 125 $this->{$methodName}($optionValue); 126 } 127 } 128 129 return $this; 130 } 131 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Feb 22 20:16:20 2023 | Cross-referenced by PHPXref 0.7.1 |