Skip to content

Instantly share code, notes, and snippets.

@derekmd
derekmd / RedisLock.php
Created February 27, 2021 23:45
Code refactor of class RedisLock from https://github.com/laravel/framework/pull/36412/
<?php
namespace Illuminate\Cache;
use Redis;
use RedisCluster;
use UnexpectedValueException;
class RedisLock extends Lock
{
@derekmd
derekmd / Optional.php
Last active October 17, 2021 10:25
Laravel global helper function `optional()`
<?php
namespace App\Support;
class Optional
{
/**
* The target being transformed.
* Use _ prefix to avoid namespace conflict on __get()
*
@derekmd
derekmd / Data_dot_data_has.php
Last active June 12, 2017 00:13
data_dot() and data_has() helper function compliments to PHP framework Laravel. Supports stdClass, Collection, or Arrayable objects along with standard PHP arrays. The intention is to allow nested wildcard pattern matching on structured data.
<?php
// app/helpers.php
// Why don't you let us order files, Gist?
use Illuminate\Support\Arr;
if (!function_exists('data_dot')) {
/**
* Flatten a multi-dimensional object with dots.