private static function getUserJson($user) { //TODO Data object implementation $userArray = array(); $yob = $user->yearOfBirth; if (StubValidator::isIntegerValid($yob) && $yob > 0) { $userArray['yob'] = $yob; } $gender = $user->gender; if ($gender != null) { if ($gender == Gender::MALE) { $userArray['gender'] = 'M'; } else { if ($gender == Gender::FEMALE) { $userArray['gender'] = 'F'; } } } return $userArray; }
/** * Returns true if this object is valid for an ad-request, false otherwise. */ public function isValid() { if (StubValidator::isDoubleValid($this->lat) != true || StubValidator::isDoubleValid($this->lon) != true || StubValidator::isIntegerValid($this->accuracy) != true) { return false; } //check for lat-lon ranges if ($this->lat <= -90 || $this->lat >= 90) { return false; } if ($this->lon <= -180 || $this->lat >= 180) { return false; } if ($this->accuracy < 0) { return false; } return true; }