class_BasePersonell.php
Go to the documentation of this file.00001 <?php
00024 class BasePersonell extends BaseFrameworkSystem implements Personellizer {
00025
00026 private $MIN_AGE = 21;
00027 private $MAX_AGE = 40;
00028
00029
00030 private $gender = "";
00031
00032
00033 private $yearBirth = 0;
00034 private $monthBirth = 0;
00035 private $dayBirth = 0;
00036
00037
00038 private $surname = "";
00039 private $family = "";
00040
00041
00042 private $employed = false;
00043
00044
00045 private $married = false;
00046
00047
00048 private $salary = 0.00;
00049
00050
00051 protected function __construct ($className) {
00052
00053 parent::__construct($className);
00054
00055
00056 $this->removeSystemArray();
00057 $this->removeNumberFormaters();
00058 }
00059
00060
00061 public final function removeMinMaxAge () {
00062 unset($this->MIN_AGE);
00063 unset($this->MAX_AGE);
00064 }
00065
00066
00067 public final function createBirthday () {
00068
00069 if ($this->isDateValid($this->yearBirth, $this->monthBirth, $this->dayBirth)) return false;
00070
00071
00072 $currYear = date("Y", time());
00073
00074
00075 $year = mt_rand(($currYear - $this->MIN_AGE), ($currYear - $this->MAX_AGE));
00076 $month = 0;
00077 $day = 0;
00078 while ($this->isDateValid($year, $month, $day) === false) {
00079 $month = mt_rand(1, 12);
00080 switch ($month) {
00081 case 1:
00082 case 3:
00083 case 5:
00084 case 7:
00085 case 8:
00086 case 10:
00087 case 12:
00088 $day = mt_rand(1, 31);
00089 break;
00090
00091 case 4:
00092 case 6:
00093 case 9:
00094 case 11:
00095 $day = mt_rand(1, 30);
00096 break;
00097
00098 case 2:
00099 if ($year % 4 == 0) {
00100
00101 $day = mt_rand(1, 29);
00102 } else {
00103
00104 $day = mt_rand(1, 28);
00105 }
00106 break;
00107 }
00108 }
00109
00110
00111 $this->setBirthday($year, $month, $day);
00112 }
00113
00114
00115 public final function isDateValid ($year, $month, $day) {
00116
00117 $stamp = mktime(0, 0, 0, $month, $day, $year);
00118
00119
00120 $y = date("Y", $stamp);
00121 $m = date("m", $stamp);
00122 $d = date("d", $stamp);
00123
00124
00125 return (($y == $year) && ($m == $month) && ($d == $day));
00126 }
00127
00128
00129 public final function isEmployed () {
00130 return $this->employed;
00131 }
00132
00133
00134 public final function isMarried () {
00135 return $this->married;
00136 }
00137
00138
00139 public final function isMale () {
00140 return ($this->gender == "M");
00141 }
00142
00143
00144 public final function isFemale () {
00145 return ($this->gender == "F");
00146 }
00147
00148
00149 public final function setSurname ($surname) {
00150 $this->surname = (string) $surname;
00151 }
00152
00153
00154 public function getSurname () {
00155 return $this->surname;
00156 }
00157
00158
00159 public final function setFamily ($family) {
00160 $this->family = (string) $family;
00161 }
00162
00163
00164 public final function getFamily () {
00165 return $this->family;
00166 }
00167
00168
00169 public final function setGender ($gender) {
00170
00171 if (($gender == "M") || ($gender == "F") || ((empty($gender)) && ($this->getSurname() == ""))) {
00172 $this->gender = $gender;
00173 } else {
00174 throw new WrongGenderSpecifiedException($gender, self::EXCEPTION_GENDER_IS_WRONG);
00175 }
00176 }
00177
00178
00179 public final function getGender () {
00180 return $this->gender;
00181 }
00182
00183
00184 public final function setEmployed ($employed) {
00185 $this->employed = (boolean) $employed;
00186 }
00187
00188
00189 public final function setMarried ($married) {
00190 $this->married = (boolean) $married;
00191 }
00192
00193
00194 public final function getSalary () {
00195 return $this->salary;
00196 }
00197
00198
00199 public final function increaseSalary ($add) {
00200 $this->salary += (float) abs($add);
00201 }
00202
00203
00204 public final function decreaseSalary ($sub) {
00205 $this->salary -= (float) abs($sub);
00206 }
00207
00208
00209 public final function setBirthday ($year, $month, $day) {
00210 $this->yearBirth = (int) abs($year);
00211 $this->monthBirth = (int) abs($month);
00212 $this->dayBirth = (int) abs($day);
00213 }
00214
00215
00216 public final function removeGender () {
00217 unset($this->gender);
00218 }
00219
00220
00221 public final function removeNames () {
00222 unset($this->surname);
00223 unset($this->family);
00224 }
00225
00226
00227 public final function removeBirthday () {
00228 unset($this->yearBirth);
00229 unset($this->monthBirth);
00230 unset($this->dayBirth);
00231 }
00232
00233
00234 public final function removeSalary () {
00235 unset($this->salary);
00236 }
00237
00238
00239 public final function removeEmployed () {
00240 unset($this->employed);
00241 }
00242
00243
00244 public final function removeMarried () {
00245 unset($this->married);
00246 }
00247 }
00248
00249
00250 ?>