class_SimulatorPersonell.php
Go to the documentation of this file.00001 <?php
00024 class SimulatorPersonell extends BasePersonell {
00025
00026 private $personellList = null;
00027
00028
00029 private $cacheList = null;
00030
00031
00032 private $cacheCond = null;
00033
00039 protected function __construct () {
00040
00041 parent::__construct(__CLASS__);
00042 }
00043
00052 public function __wakeup () {
00053
00054 $this->removePersonellList();
00055 $this->removeMinMaxAge();
00056 $this->removeCache();
00057 $this->removeSystemArray();
00058 }
00059
00068 public final static function createSimulatorPersonell ($amountPersonell) {
00069
00070 $amountPersonell = (int) $amountPersonell;
00071
00072
00073 $personellInstance = new SimulatorPersonell();
00074
00075
00076 if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->debugOutput(sprintf("[%s:%d] Es werden <strong>%d</strong> Personal bereitgestellt.",
00077 __CLASS__,
00078 __LINE__,
00079 $amountPersonell
00080 ));
00081
00082
00083 $personellInstance->createPersonellList();
00084
00085
00086 for ($idx = 0; $idx < $amountPersonell; $idx++) {
00087 $personellInstance->addRandomPersonell();
00088 }
00089
00090
00091 if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $personellInstance->debugOutput(sprintf("[%s:%d] <strong>%d</strong> Personal bereitgestellt.",
00092 __CLASS__,
00093 __LINE__,
00094 $amountPersonell
00095 ));
00096
00097
00098 $personellInstance->removeGender();
00099 $personellInstance->removeNames();
00100 $personellInstance->removeBirthday();
00101 $personellInstance->removeSalary();
00102 $personellInstance->removeEmployed();
00103 $personellInstance->removeMarried();
00104 $personellInstance->removeNumberFormaters();
00105
00106 $personellInstance->removeSystemArray();
00107
00108
00109 return $personellInstance;
00110 }
00111
00123 public final static function createSimulatorPersonellByID ($idNumber) {
00124
00125 $personellInstance = new SimulatorPersonell(false);
00126 $personellInstance->makeDeprecated();
00127 }
00128
00129
00130 public function createPersonellList () {
00131
00132 if ($this->personelllList instanceof FrameworkArrayObject) {
00133
00134 throw new PersonellListAlreadyCreatedException($this, self::EXCEPTION_DIMENSION_ARRAY_INVALID);
00135 }
00136
00137
00138 $this->personellList = new FrameworkArrayObject("FakedPersonellList");
00139 }
00140
00141
00142 private final function removePersonellList () {
00143 unset($this->personellList);
00144 }
00145
00146
00147 public function addRandomPersonell () {
00148
00149 $genders = array("M", "F");
00150
00151
00152 $personellInstance = new SimulatorPersonell();
00153
00154
00155 $personellInstance->setGender($genders[mt_rand(0, 1)]);
00156
00157
00158 $personellInstance->createBirthday();
00159
00160
00161 if (mt_rand(0, 5) == mt_rand(0, 5)) $personellInstance->setMarried(true);
00162
00163
00164 $personellInstance->removePersonellList();
00165 $personellInstance->removeMinMaxAge();
00166 $personellInstance->removeCache();
00167 $personellInstance->removeSystemArray();
00168
00169
00170 $this->personellList->append($personellInstance);
00171 }
00172
00178 function getSpecialPersonellList ($isEmployed = null, $isMarried = null, $hasGender = "") {
00179
00180 $serialized = serialize(array($isEmployed, $isMarried, $hasGender));
00181
00182
00183 if (($serialized == $this->cacheCond) && (!is_null($this->cacheCond))) {
00184 if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Gecachte Liste wird verwendet.",
00185 __CLASS__,
00186 __LINE__
00187 ));
00188
00189
00190 return $this->cacheList;
00191 }
00192
00193
00194 if ((defined('DEBUG_PERSONELL')) || (defined('DEBUG_ALL'))) $this->debugOutput(sprintf("[%s:%d] Personalliste wird nach Kriterien durchsucht...",
00195 __CLASS__,
00196 __LINE__
00197 ));
00198
00199
00200 $this->setCacheCond($serialized);
00201
00202
00203 $this->setAllCacheList(new FrameworkArrayObject('FakedCacheList'));
00204
00205
00206 for ($idx = $this->personellList->getIterator(); $idx->valid(); $idx->next()) {
00207
00208 $el = $idx->current();
00209
00210
00211 if ((!is_null($isEmployed)) && ($el->isEmployed() == $isEmployed)) {
00212
00213 $this->cacheList->append($el);
00214 } elseif ((!is_null($isMarried)) && ($el->isMarried() == $isMarried)) {
00215
00216 $this->cacheList->append($el);
00217 } elseif ((!empty($hasGender)) && ($el->getGender() == $hasGender)) {
00218
00219 $this->cacheList->append($el);
00220 }
00221 }
00222
00223
00224 return $this->cacheList;
00225 }
00226
00232 public final function getAllUnemployed () {
00233
00234 $list = $this->getSpecialPersonellList(false);
00235
00236
00237 return $list->count();
00238 }
00239
00245 private function removeCache () {
00246
00247 unset($this->cacheList);
00248 unset($this->cacheCond);
00249 }
00250
00257 private final function setAllCacheList (FrameworkArrayObject $cacheList = null) {
00258 $this->cacheList = $cacheList;
00259 }
00260
00267 private final function setCacheCond ($cacheCond) {
00268 $this->cacheCond = (string) $cacheCond;
00269 }
00270
00276 public function resetCache () {
00277 $this->setAllCacheList(null);
00278 $this->setCacheCond("");
00279 }
00280
00287 public final function getSurname () {
00288 $surname = parent::getSurname();
00289
00290
00291 if (empty($surname)) {
00292 if ($this->isMale()) {
00293
00294 $surname = "John";
00295 } else {
00296
00297 $surname = "Jennifer";
00298 }
00299
00300
00301 parent::setFamily("Smith");
00302 }
00303
00304
00305 return $surname;
00306 }
00307
00313 public final function getPersonellList () {
00314 return $this->personellList;
00315 }
00316
00325 public function loadPersonellList ($idNumber) {
00326 $this->makeDeprecated();
00327 }
00328 }
00329
00330
00331 ?>