HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Users/Genders.php
<?php

namespace App\Komma\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
     */
    public 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
     */
    public 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();
    }
}