initial commit

This commit is contained in:
2022-01-04 13:27:11 -07:00
parent 3764dad884
commit aed6ca46c2
63 changed files with 3780 additions and 1 deletions

View File

@ -0,0 +1,11 @@
<?php
define('CACHE_TTL_FIVE_MINUTES', 300);
define('CACHE_TTL_FIFTEEN_MINUTES', 900);
define('CACHE_TTL_HALF_HOUR', 1800);
define('CACHE_TTL_ONE_HOUR', 3600);
define('CACHE_TTL_ONE_DAY', 86400);
define('CACHE_TTL_ONE_WEEK', 604800);

View File

@ -0,0 +1,56 @@
<?php
$httpCodes = [
// 200's (successful)
200 => 'HTTP_SUCCESS',
201 => 'HTTP_CREATED',
202 => 'HTTP_ACCEPTED',
204 => 'HTTP_NO_CONTENT',
205 => 'HTTP_RESET_CONTENT',
206 => 'HTTP_PARTIAL_CONTENT',
208 => 'HTTP_ALREADY_REPORTED',
// 300's (redirections)
301 => 'HTTP_MOVED_PERMANENTLY',
302 => 'HTTP_REDIRECT_FOUND',
304 => 'HTTP_NOT_MODIFIED',
307 => 'HTTP_TEMP_REDIRECT',
308 => 'HTTP_PERMANENT_REDIRECT',
// 400's (app got the request but couldn't process it successfully, coding error)
400 => 'HTTP_BAD_REQUEST',
401 => 'HTTP_UNAUTHORIZED',
402 => 'HTTP_PAYMENT_REQUIRED',
403 => 'HTTP_FORBIDDEN',
404 => 'HTTP_NOT_FOUND',
405 => 'HTTP_METHOD_NOT_ALLOWED',
406 => 'HTTP_NOT_ACCEPTABLE',
408 => 'HTTP_TIMEOUT',
409 => 'HTTP_CONFLICT',
410 => 'HTTP_GONE',
412 => 'HTTP_PRECONDITION_FAILED',
413 => 'HTTP_PAYLOAD_TOO_LARGE',
415 => 'HTTP_UNSUPPORTED_MEDIA',
413 => 'HTTP_TOO_LARGE',
417 => 'HTTP_EXPECTATION_FAIL',
418 => 'HTTP_TEAPOT',
422 => 'HTTP_UNPROCESSABLE_ENTITY',
423 => 'HTTP_LOCKED',
424 => 'HTTP_FAILED_DEPENDENCY',
236 => 'HTTP_UPGRADE_REQUIRED',
428 => 'HTTP_PRECONDITION_REQUIRED',
429 => 'HTTP_TOO_MANY_REQUESTS',
451 => 'HTTP_GAG_ORDER',
// 500's (server-level problem, process died or configuration is incorrect)
500 => 'HTTP_SERVER_ERROR',
501 => 'HTTP_NOT_IMPLEMENTED',
503 => 'HTTP_UNAVAILABLE',
530 => 'HTTP_SUSPENDED',
];
foreach ($httpCodes as $code => $slug) {
if (! defined($slug)) {
define($slug, $code);
}
}

View File

@ -0,0 +1,43 @@
<?php
if (! function_exists('snake2Title')) {
/**
* Convert a snake case string to a title with spaces
* and every word capitalized.
*
* @param string $stakeSlug A snake case string, commonly a slug
*
* @return string
*/
function snake2Title(string $snakeSlug): string
{
$output = preg_replace('/\_/', ' ', $snakeSlug);
return ucwords($output);
}
}
if (! function_exists('carbon')) {
function carbon(?string $timestring = null)
{
$carbon = Carbon\Carbon::now(session('timezone_name'));
if (! empty($timestring)) {
$carbon = Carbon\Carbon::parse($timestring, session('timezone_name'));
}
return $carbon;
}
}
if (! function_exists('jddayofweek')) {
function jddayofweek(?int $intDay = null, int $mode = 0)
{
if (is_null($intDay)) {
$intDay = date('l');
}
if ($mode === 0) {
return $intDay;
}
return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][$intDay];
}
}