Skip to content

Instantly share code, notes, and snippets.

View jason-napolitano's full-sized avatar
:octocat:
Working everywhere

Jason Napolitano jason-napolitano

:octocat:
Working everywhere
View GitHub Profile
@jason-napolitano
jason-napolitano / Str.php
Last active September 15, 2023 19:00
PHP String Helper Class
<?php
class Str
{
/** @var array|string[] $plural Array of pluralized words */
private static array $plural = [
'/(quiz)$/i' => "$1zes",
'/^(ox)$/i' => "$1en",
'/([m|l])ouse$/i' => "$1ice",
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
@jason-napolitano
jason-napolitano / FileUploader.php
Last active March 22, 2022 03:53
A Laravel file helper class that assists in uploading files to the file server. Stick in app/Helpers or change the namespace to match your project.
<?php
namespace App\Helpers;
use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\File;
/**
* The file upload helper makes it easier to upload files
@jason-napolitano
jason-napolitano / .prettierrc.json
Last active May 4, 2023 01:33
.prettierrc.json
{
"$schema": "https://json.schemastore.org/prettierrc",
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"jsxBracketSameLine": false,
"printWidth": 80,
"proseWrap": "preserve",
"requirePragma": false,
"semi": false,
@jason-napolitano
jason-napolitano / Session.php
Last active November 10, 2023 21:50
Session.php
<?php
/**
* ------------------------------------------------------------------------
* The Session Library Class is a utility wrapper class that assists in the
* handling of sessions in PHP applications. We achieve this by creating an
* abstraction between the developer and PHP's native session library. Thus
* providing a factory that can manufacture, modify and manage session data
* ------------------------------------------------------------------------
*
<?php
/**
* A facade class for the Core Router Module. Used to make routed calls using
* more practical and simple invocations for each Route.
*
* @author Jason Napolitano <jnapolitanoit@gmail.com>
* @license MIT
*/
abstract class RouteHandler
@jason-napolitano
jason-napolitano / DotEnv.php
Created December 20, 2020 20:35
DotEnv.php
<?php
/**
* Environment-specific configuration. This class was extracted directly from the CodeIgniter 4
* framework and upgraded to use features from PHP >=8.0.0
*
*
* @link https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Config/DotEnv.php
*/
class DotEnv
@jason-napolitano
jason-napolitano / Logger.php
Last active December 5, 2020 21:10
Logger.php
<?php
// Import LogLevel Class
use \Psr\Log\LogLevel;
/**
* ----------------------------------------------------------------------------
* The Logger Library Class is a utility class that assists in the
* logging application of activity.
*
@jason-napolitano
jason-napolitano / Autoload.php
Last active January 29, 2021 06:46
Autoload.php
<?php
/**
* ----------------------------------------------------------------------------
* The Autoload Library is a PSR-4 compatible utility class that assists in
* loading of package classmaps and namespaces. Run Autoload::register() to
* instantiate
*
* @author Jason Napolitano <jnapolitanoit@gmail.com>
* @link https://www.php-fig.org/psr/psr-4/
@jason-napolitano
jason-napolitano / constants.php
Last active October 18, 2020 16:59
A file that contains a ton of cool constants for PHP projects. Geared for the CodeIgniter framework, but it is not required.
<?php defined('BASEPATH') || exit('No direct script access allowed');
/**
* --------------------------------------------------------------------------
* Application Specific Constants
* --------------------------------------------------------------------------
*
* The following constants are application specific. They cover items such as
* writable path values, HTTP status codes and more!
*
* @package Constants
@jason-napolitano
jason-napolitano / JWT.php
Last active May 30, 2020 21:31
A simple PHP library class and interface to assist with JSON Web Tokens
<?php defined('BASEPATH') || exit('Access Denied');
/**
* Library for a JSON Web Token implementation based on the JWT Spec
*
* @category Libraries
* @author Jason Napolitano <jnapolitanoit@gmail.com>
* @updated 10.11.2018
*
* @license 2-clause BSD