Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
AmyStephen / Files.php
Last active July 5, 2017 17:47
General purpose folder and file processing for copy, move, delete, and size calculation
<?php
/**
* File class
*
* @package Molajo
* @copyright 2013 Amy Stephen. All rights reserved.
* @license MIT, GPL v2 or later
*/
namespace Molajo;
@AmyStephen
AmyStephen / Data.php
Last active December 12, 2015 01:08
Freaking dots.
<?php
/**
* Discovery retrieves folder and file names
*
* @param $path
*
* @return void
* @since 1.0
*/
public function discovery($path)
@AmyStephen
AmyStephen / LocalWriteTest.php
Last active June 15, 2018 20:05
Delete all files and folders in a directory
<?php
$this->path = BASE_FOLDER . '/x/y/z';
if (file_exists($this->path)) {
$objects = new RecursiveIteratorIterator (
new RecursiveDirectoryIterator($this->path),
RecursiveIteratorIterator::SELF_FIRST);
$directories = array();
@AmyStephen
AmyStephen / StaticImplementation.php
Created January 24, 2013 11:21
PSR-3 Static Factory Approach
<?php
use Psr\Log\LoggerInterface;
class Foo
{
private $logger;
public function __construct()
{
@AmyStephen
AmyStephen / CacheInterface.php
Created January 16, 2013 04:43
Simple Cache Interface
<?php
interface Cache
{
/**
* Does cache exist for the key?
*
* @param string $key Key value used to store cache
*
* @return bool
*/
@AmyStephen
AmyStephen / Example1.php
Last active December 11, 2015 00:59
JPlatform Namespace Examples
<?php
/**
* @package Joomla.Platform
* @subpackage Document
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Example1;
@AmyStephen
AmyStephen / Document.php
Created January 4, 2013 22:56
Implications of use statements on overrides - JDocument Relates to: https://github.com/joomla/joomla-platform/blob/staging/libraries/joomla/document/document.php Example 1: uses dependency injection to pass in the Namespace and the Alias. This enables overriding the location of the class file so that the class can be overridden. The core HTML cl…
namespace Joomla\Document;
class JDocument
{
public function __construct($options = array())
{
if (array_key_exists('lineend', $options))
{
$this->setLineEnd($options['lineend']);
@AmyStephen
AmyStephen / gist:4191177
Created December 2, 2012 21:37
I will never get this time back.
unset($this->model_registry_name);
$this->onAfterSetDataobjectEvent();
Services::Registry()->get($this->model_registry_name, '*');
@AmyStephen
AmyStephen / Services.php
Created December 2, 2012 16:57
Services Mock up
<?php
/**
* @package Molajo
* @copyright 2012 Amy Stephen. All rights reserved.
* @license GNU GPL v 2, or later and MIT, see License folder
*/
namespace Molajo\Service;
use Molajo\Application;
use Molajo\Service\Services\Configuration\ConfigurationService;
@AmyStephen
AmyStephen / ExceptionService.php
Created November 28, 2012 19:05
Custom Exception Handler
<?php
/**
* @package Molajo
* @copyright 2012 Individual Molajo Contributors. All rights reserved.
* @license GNU GPL v 2, or later and MIT, see License folder
*/
namespace Molajo\Service\Services\Exception;
use Molajo\Service\Services;
use \Exception;