<?php

if (!function_exists('numberSuffix')) {
    function numberSuffix($number) {
        if (!is_int($number) || $number < 1) {
            return $number;
        }

        $lastDigit = $number % 10;
        $secondLastDigit = ($number / 10) % 10;

        if ($secondLastDigit == 1) {
            return 'th';
        }

        switch ($lastDigit) {
            case 1:
                return 'st';
            case 2:
                return 'nd';
            case 3:
                return 'rd';
            default:
                return 'th';
        }
    }
}
