Made the following changes: Removed class, standardised property names to camel case and switched method names.

This commit is contained in:
Matt Kirwan
2013-08-05 16:23:28 +01:00
parent eda4616331
commit 8991c3f013

View File

@@ -165,27 +165,27 @@ interface OutputInterface
public function load(); public function load();
} }
class OutputSerializedArray implements OutputInterface class SerializedArrayOutput implements OutputInterface
{ {
public function load() public function load()
{ {
return serialize($array_of_data); return serialize($arrayOfData);
} }
} }
class OutputJsonString implements OutputInterface class JsonStringOutput implements OutputInterface
{ {
public function load() public function load()
{ {
return json_encode($array_of_data); return json_encode($arrayOfData);
} }
} }
class OutputArray implements OutputInterface class ArrayOutput implements OutputInterface
{ {
public function load() public function load()
{ {
return $array_of_data; return $arrayOfData;
} }
} }
{% endhighlight %} {% endhighlight %}
@@ -203,15 +203,13 @@ behaviour required at runtime:
{% highlight php %} {% highlight php %}
<?php <?php
class SomeClientClass class SomeClient
{ {
private $output; private $output;
public function __construct(){} public function setOutput(OutputInterface $outputType)
public function setOutput(OutputInterface $output_type)
{ {
$this->output = $output_type; $this->output = $outputType;
} }
public function loadOutput() public function loadOutput()
@@ -227,14 +225,14 @@ that has been set.
{% highlight php %} {% highlight php %}
<?php <?php
$client = new SomeClientClass(); $client = new SomeClient();
// Want an array? // Want an array?
$client->setOutput(new OutputArray()); $client->setOutput(new ArrayOutput());
$data = $client->loadOutput(); $data = $client->loadOutput();
// Want some JSON? // Want some JSON?
$client->setOutput(new OutputJsonString()); $client->setOutput(new JsonStringOutput());
$data = $client->loadOutput(); $data = $client->loadOutput();
{% endhighlight %} {% endhighlight %}