Right click > Select "View Page Source" to see source code.
EXAMPLE 1:
// example of creating an enum in PHP
<?php
abstract class PeriodEnum {
const Day = 'day';
const Week = 'week';
const Month = 'month';
const All = 'all';
public static function isValidPeriod($period, $strict = false) {
$constants = array(self::Day => self::Day, self::Week => self::Week, self::Month => self::Month, self::All => self::All);
if ($strict) {
return array_key_exists($period, $constants);
}
$keys = array_map('strtolower', array_keys($constants));
return in_array(strtolower($period), $keys);
}
}
?>
EXAMPLE 2:
// example of creating a clamp function in PHP
<?php
function clamp($current, $min, $max) {
return max($min, min($max, $current));
}
?>