This file contains hidden or 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
<?php | |
use Pimple\Container; | |
use Charcoal\Model\ModelInterface; | |
use Charcoal\Model\CollectionInterface; | |
use App\Post; | |
$container = new Container(); | |
$container['cache'] = function (Container $container) { |
This file contains hidden or 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
<?php | |
/** | |
* Convert array to an object recursively, a new instances of the stdClass. | |
* | |
* @param array $props The array to convert into an object. | |
* @return object | |
*/ | |
function props(array $props) : object | |
{ |
This file contains hidden or 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
<?php | |
/** | |
* Call the callback with one or all handlers disabled for the given action or filter. | |
* | |
* Temporarily disables the specified hook, or all hooks, from a specified filter or action | |
* before calling $callback. | |
* | |
* @link https://gist.github.com/westonruter/6647252 | |
* |
This file contains hidden or 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
<?php | |
/** | |
* Hook a function or method to an array of actions. | |
* | |
* @param string[] $tags Array of names of filters to hook the $function callback to. | |
* @param callable $function_to_add The callback to be run when the filter is applied. | |
* @param int $priority Optional. Used to specify the order in which the functions | |
* associated with a particular action are executed. Default 10. | |
* @param int $accepted_args Optional. The number of arguments the function accepts. Default 1. |
This file contains hidden or 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
<?php | |
if (!function_exists('array_chunk_by')) { | |
/** | |
* Splits an array into chunks using a callback function. | |
* | |
* Chunks an array into arrays by iteratively applying the $callback function | |
* to the elements of the $array. | |
* | |
* @see https://rlaanemets.com/post/show/group-array-by-adjacent-elements-in-javascript |
This file contains hidden or 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
<?php | |
use Larabros\Elogram\Client; | |
header('Content-Type: application/json;charset=utf-8'); | |
/** Register the Composer autoloader */ | |
require dirname(__DIR__) . '/vendor/autoload.php'; | |
$clientId = ''; |
This file contains hidden or 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
if (!String.prototype.explode) { | |
/** | |
* Split a string by string | |
* | |
* Splits a String object into an array of substrings, each of which is formed | |
* by splitting it on boundaries formed by the string delimiter. | |
* | |
* @link http://locutus.io/php/explode/ Created by Kevin van Zonneveld (http://kvz.io) | |
* @example | |
* 'Kevin van Zonneveld'.explode(' ') // [ 'Kevin', 'van', 'Zonneveld' ] |
This file contains hidden or 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
<?php | |
if (!function_exists('is_blank')) { | |
/** | |
* Determine whether a variable has a non-empty value. | |
* | |
* Alternative to {@see empty()} that accepts non-empty values: | |
* - _0_ (0 as an integer) | |
* - _0.0_ (0 as a float) | |
* - _"0"_ (0 as a string) |
This file contains hidden or 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
<?php | |
/** | |
* Route Aliases & Redirections | |
* | |
* @global App $app The Charcoal application. | |
* @global Container $container The DIC. | |
* @todo Add support for request method lookup, not just response method. | |
*/ |
This file contains hidden or 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
<?php | |
/** | |
* Compose the given functions into a new one (`a(b(c(x)))`). | |
* | |
* Similar to {@see sequence()}, except the function list is executed in reverse — | |
* the last function is executed first. | |
* | |
* ``` | |
* compose(a, b, c) => a(b(c(x))) |