John Squibb

Appliance Base Classes

This page contains base classes that are needed for the various appliances.

Base classes are subject to frequent addition and modification, so check back regularly!

Debug Helper

A simple class for dumping trace messages to the command line.

<?php
namespace Debug;

// Debug helper for displaying messages
class Trace
{
    public static function 
out($message)
    {
        print 
"TRACE: {$message}\n";
    }
}

Toggle plain-text

Interval Helper

Standardizes time intervals, so that you do not have to use any arbitrary sleep() calls in the various appliances.

<?php
namespace Time;

// Interval helper. Helps pass the time!
class Interval
{
    
/**
     * Length of time in microseconds. 
     * You can shorten this to manipulate time for your purposes.
     */
    
const TICK 1000000;
    
    
/**
     * Modifiers
     */
    
const MINUTES_TO_SECONDS 60;
    
    public static function 
get($modifier$amount)
    {
        return 
$modifier $amount;
    }
    
    public static function 
tick()
    {
        
usleep(self::TICK);
    }
}

Toggle plain-text

Tags: Bash,image,resize,imagemagick,php 5.3,google linux search,class constants, magic numbers
Short URL: http://sqb.in/u2t5