Skip to content

Commit

Permalink
Made the following changes: Removed class, standardised property name…
Browse files Browse the repository at this point in the history
…s to camel case and switched method names.
  • Loading branch information
Matt Kirwan committed Aug 5, 2013
1 parent eda4616 commit 8991c3f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions pages/Design-Patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,27 +165,27 @@ interface OutputInterface
public function load();
}
class OutputSerializedArray implements OutputInterface
class SerializedArrayOutput implements OutputInterface
{
public function load()
{
return serialize($array_of_data);
return serialize($arrayOfData);
}
}
class OutputJsonString implements OutputInterface
class JsonStringOutput implements OutputInterface
{
public function load()
{
return json_encode($array_of_data);
return json_encode($arrayOfData);
}
}
class OutputArray implements OutputInterface
class ArrayOutput implements OutputInterface
{
public function load()
{
return $array_of_data;
return $arrayOfData;
}
}
{% endhighlight %}
Expand All @@ -203,15 +203,13 @@ behaviour required at runtime:
{% highlight php %}
<?php
class SomeClientClass
class SomeClient
{
private $output;
public function __construct(){}
public function setOutput(OutputInterface $output_type)
public function setOutput(OutputInterface $outputType)
{
$this->output = $output_type;
$this->output = $outputType;
}

public function loadOutput()
Expand All @@ -227,14 +225,14 @@ that has been set.
{% highlight php %}
<?php
$client = new SomeClientClass();
$client = new SomeClient();
// Want an array?
$client->setOutput(new OutputArray());
$client->setOutput(new ArrayOutput());
$data = $client->loadOutput();

// Want some JSON?
$client->setOutput(new OutputJsonString());
$client->setOutput(new JsonStringOutput());
$data = $client->loadOutput();

{% endhighlight %}
Expand Down

0 comments on commit 8991c3f

Please sign in to comment.