Skip to content

Commit

Permalink
updates to demo script to use new debugger factory
Browse files Browse the repository at this point in the history
  • Loading branch information
lancecaraccioli committed Jun 25, 2013
1 parent 1d52cff commit 5034f78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 34 deletions.
44 changes: 18 additions & 26 deletions examples/lc.debug.php
Expand Up @@ -3,51 +3,43 @@
get_include_path(),
realpath(__DIR__ . '/../library/'),
)));
use LC\Debug;
use LC\Debug\Writer\Html;
use LC\Debug\Writer\Chrome;
use LC\Debug\Writer\CommandLine;
use LC\Debug\Writer\Email;

require_once('LC/Debug.php');
require_once('LC/Debug/Writer/Html.php');
require_once('LC/Debug/Writer/CommandLine.php');
require_once('LC/Debug/Writer/Email.php');
require_once('LC/Debug/Writer/Chrome.php');
use LC\Debug\Factory;

/**
* Because debugging is a development time type of functionality that is typically not very coupled to anything, set up a convient
* global functions named "dump" and "kill" to wrap the debugger... base the adapter on a configuration option...
* in an ideal world a dependecy injection container would be setup to handle the wiring.
*/
$debuggerFactory = new Factory();

$debugger = new Debug();
/**
* demo data
*/
$data = array(
'foo' => 'bar',
'zoo' => 'jar',
'etc' => 'ect'
'foo' => 'foo value',
'bar' => 'bar value',
'baz' => 'baz value'
);

//chrome
$writer = new Chrome();
$debugger->setWriter($writer);
$debugger->dump($data);
$debugger = $debuggerFactory->buildDebuggerWithChromeWriter();
$debugger->dump($data); //dump chrome dev tools console format

//html
$writer = new Html();
$debugger->setWriter($writer);
$debugger->dump($data);
$debugger = $debuggerFactory->buildDebuggerWithHtmlWriter();
$debugger->dump($data); //dump html output format

//command line
$writer = new CommandLine();
$debugger->setWriter($writer);
$debugger->dump($data);
$debugger = $debuggerFactory->buildDebuggerWithCommandLineWriter();
$debugger->dump($data);//dump command line output format


/**
* @todo implement basic email transport for proof of concept (was using Zend_Mail, but wanted to decouple)
* @todo implement basic email transport for proof of concept perhaps using as default transport (was using Zend_Mail, but wanted to decouple)
*
* $writer = new Email();
* $transport = new <class implementation of EmailTransport>
* $debugger = $debuggerFactory->buildDebuggerWithCommandLineWriter();
* $debugger->dump($data);//send email
*/


Expand Down
14 changes: 6 additions & 8 deletions library/LC/Debug/EmailTransport.php
@@ -1,17 +1,15 @@
<?
namespace LC\Debug;

abstract class EmailTransport
interface EmailTransport
{
public function setBodyText();

public abstract function setBodyText();
public function setBodyHtml();

public abstract function setBodyHtml();
public function setSubject();

public abstract function setSubject();

public abstract function setRecipient();

public abstract function send();
public function setRecipient();

public function send();
}
6 changes: 6 additions & 0 deletions library/LC/Debug/Factory.php
Expand Up @@ -24,6 +24,12 @@ class Factory
const chrome = 'chrome';
const email = 'email';

public static function make($type)
{
$factory = new self();
return $factory->build($type);
}

public function build($type)
{
$myReflection = new ReflectionClass($this);
Expand Down

0 comments on commit 5034f78

Please sign in to comment.