File: D:/HostingSpaces/SBogers10/mountadvies.komma.pro/app/Users/Genders.php
<?php
namespace App\Users;
/**
* Class Gender
*
* Represents user genders.
* Will be replaced by the Gender model since this is a interim solution
*/
abstract class Genders
{
const Unknown = 0;
const Male = 1;
const Female = 2;
// const Neutral = 3;
/**
* @return int[] All genders as an array of integers
*/
static function getAsArray() {
return self::getAllGenders();
}
/**
* Check if the passed gender is really a gender that is defined as a constant in this class.
*
* @param int $gender
* @param bool $strict If true it will only consider a gender as valid if it is an int. If it for example is a numeric string it won't consider it valid
* @return bool Returns true if the gender is a valid one, false otherwise
*/
static function isValidGender(int $gender, $strict = false) {
return in_array($gender, self::getAllGenders(), $strict);
}
/**
* Returns an array containing integers representing the defined genders.
*
* @return int[]
*/
private static function getAllGenders()
{
$thisClassAsReflectionClass = new \ReflectionClass(__CLASS__);
return $thisClassAsReflectionClass->getConstants();
}
}