[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Configurator\JavaScript; 9 10 class ConfigValue 11 { 12 /** 13 * @var bool 14 */ 15 protected $isDeduplicated = false; 16 17 /** 18 * @var string Name of the variable that holds this value 19 */ 20 protected $name; 21 22 /** 23 * @var integer Number of times this value is used or referenced 24 */ 25 protected $useCount = 0; 26 27 /** 28 * @var array|Code|Dictionary Original value 29 */ 30 protected $value; 31 32 /** 33 * @var string 34 */ 35 protected $varName; 36 37 /** 38 * Constructor 39 * 40 * @param array|Code|Dictionary $value Original value 41 * @param string $varName 42 */ 43 public function __construct($value, $varName) 44 { 45 $this->value = $value; 46 $this->varName = $varName; 47 } 48 49 /** 50 * Mark this value as deduplicated if it's been used more than once 51 * 52 * @return void 53 */ 54 public function deduplicate() 55 { 56 if ($this->useCount > 1) 57 { 58 $this->isDeduplicated = true; 59 $this->decrementUseCount($this->useCount - 1); 60 } 61 } 62 63 /** 64 * Return the number of times this value has been used or referenced 65 * 66 * @return integer 67 */ 68 public function getUseCount() 69 { 70 return $this->useCount; 71 } 72 73 /** 74 * Return the PHP value held by this instance 75 * 76 * @return array|Code|Dictionary 77 */ 78 public function getValue() 79 { 80 return $this->value; 81 } 82 83 /** 84 * Return the variable name assigned to this value 85 * 86 * @return string 87 */ 88 public function getVarName() 89 { 90 return $this->varName; 91 } 92 93 /** 94 * Increment the use counter 95 * 96 * @return void 97 */ 98 public function incrementUseCount() 99 { 100 ++$this->useCount; 101 } 102 103 /** 104 * Return whether this value is marked as deduplicated 105 * 106 * @return bool 107 */ 108 public function isDeduplicated() 109 { 110 return $this->isDeduplicated; 111 } 112 113 /** 114 * Decrement the use counter of this value as well as the values it contains 115 * 116 * @param integer $step How much to remove from the counter 117 * @return void 118 */ 119 protected function decrementUseCount($step = 1) 120 { 121 $this->useCount -= $step; 122 foreach ($this->value as $value) 123 { 124 if ($value instanceof ConfigValue) 125 { 126 $value->decrementUseCount($step); 127 } 128 } 129 } 130 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |