Created
December 1, 2019 06:03
-
-
Save cmcintosh/40af561958519db6d098f215b5a4d028 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Merges max-age values (expressed in seconds), finds the lowest max-age. | |
* | |
* Ensures infinite max-age (Cache::PERMANENT) is taken into account. | |
* | |
* @param int $a | |
* Max age value to merge. | |
* @param int $b | |
* Max age value to merge. | |
* | |
* @return int | |
* The minimum max-age value. | |
*/ | |
public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT) { | |
// If one of the values is Cache::PERMANENT, return the other value. | |
if ($a === Cache::PERMANENT || $a == 0) { | |
return $b; | |
} | |
if ($b === Cache::PERMANENT || $b == 0) { | |
return $a; | |
} | |
// If none or the values are Cache::PERMANENT, return the minimum value. | |
return min($a, $b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment