diff --git a/AbstractFactory/AbstractFactory.php b/AbstractFactory/AbstractFactory.php
index b3794d9..e322325 100644
--- a/AbstractFactory/AbstractFactory.php
+++ b/AbstractFactory/AbstractFactory.php
@@ -28,6 +28,7 @@ abstract class AbstractFactory
* Creates a text component
*
* @param string $content
+ *
* @return Text
*/
abstract public function createText($content);
@@ -37,6 +38,7 @@ abstract class AbstractFactory
*
* @param string $path
* @param string $name
+ *
* @return Picture
*/
abstract public function createPicture($path, $name = '');
diff --git a/AbstractFactory/Html/Picture.php b/AbstractFactory/Html/Picture.php
index c678cf1..2e648b0 100644
--- a/AbstractFactory/Html/Picture.php
+++ b/AbstractFactory/Html/Picture.php
@@ -11,7 +11,6 @@ use DesignPatterns\AbstractFactory\Picture as BasePicture;
*/
class Picture extends BasePicture
{
-
/**
* some crude rendering from HTML output
*
@@ -19,7 +18,6 @@ class Picture extends BasePicture
*/
public function render()
{
- return sprintf('
', $this->_path, $this->_name);
+ return sprintf('
', $this->path, $this->name);
}
-
}
diff --git a/AbstractFactory/Html/Text.php b/AbstractFactory/Html/Text.php
index 4e626e2..8ea6d4f 100644
--- a/AbstractFactory/Html/Text.php
+++ b/AbstractFactory/Html/Text.php
@@ -11,7 +11,6 @@ use DesignPatterns\AbstractFactory\Text as BaseText;
*/
class Text extends BaseText
{
-
/**
* some crude rendering from HTML output
*
@@ -19,7 +18,6 @@ class Text extends BaseText
*/
public function render()
{
- return '
' . htmlspecialchars($this->_text) . '
';
+ return '' . htmlspecialchars($this->text) . '
';
}
-
}
diff --git a/AbstractFactory/HtmlFactory.php b/AbstractFactory/HtmlFactory.php
index dad71b9..3606374 100644
--- a/AbstractFactory/HtmlFactory.php
+++ b/AbstractFactory/HtmlFactory.php
@@ -9,12 +9,12 @@ namespace DesignPatterns\AbstractFactory;
*/
class HtmlFactory extends AbstractFactory
{
-
/**
* Creates a picture component
*
* @param string $path
* @param string $name
+ *
* @return Html\Picture|Picture
*/
public function createPicture($path, $name = '')
@@ -26,11 +26,11 @@ class HtmlFactory extends AbstractFactory
* Creates a text component
*
* @param string $content
+ *
* @return Html\Text|Text
*/
public function createText($content)
{
return new Html\Text($content);
}
-
}
diff --git a/AbstractFactory/Json/Picture.php b/AbstractFactory/Json/Picture.php
index 179aa3a..4684191 100644
--- a/AbstractFactory/Json/Picture.php
+++ b/AbstractFactory/Json/Picture.php
@@ -11,7 +11,6 @@ use DesignPatterns\AbstractFactory\Picture as BasePicture;
*/
class Picture extends BasePicture
{
-
/**
* some crude rendering from JSON output
*
@@ -19,7 +18,6 @@ class Picture extends BasePicture
*/
public function render()
{
- return json_encode(array('title' => $this->_name, 'path' => $this->_path));
+ return json_encode(array('title' => $this->name, 'path' => $this->path));
}
-
}
diff --git a/AbstractFactory/Json/Text.php b/AbstractFactory/Json/Text.php
index 91115e8..83d0877 100644
--- a/AbstractFactory/Json/Text.php
+++ b/AbstractFactory/Json/Text.php
@@ -11,7 +11,6 @@ use DesignPatterns\AbstractFactory\Text as BaseText;
*/
class Text extends BaseText
{
-
/**
* some crude rendering from JSON output
*
@@ -19,7 +18,6 @@ class Text extends BaseText
*/
public function render()
{
- return json_encode(array('content' => $this->_text));
+ return json_encode(array('content' => $this->text));
}
-
}
diff --git a/AbstractFactory/JsonFactory.php b/AbstractFactory/JsonFactory.php
index 814fbaf..6cf15d2 100644
--- a/AbstractFactory/JsonFactory.php
+++ b/AbstractFactory/JsonFactory.php
@@ -16,6 +16,7 @@ class JsonFactory extends AbstractFactory
*
* @param string $path
* @param string $name
+ *
* @return Json\Picture|Picture
*/
public function createPicture($path, $name = '')
@@ -23,16 +24,15 @@ class JsonFactory extends AbstractFactory
return new Json\Picture($path, $name);
}
-
/**
* Creates a text component
*
* @param string $content
+ *
* @return Json\Text|Text
*/
public function createText($content)
{
return new Json\Text($content);
}
-
}
diff --git a/AbstractFactory/Media.php b/AbstractFactory/MediaInterface.php
similarity index 85%
rename from AbstractFactory/Media.php
rename to AbstractFactory/MediaInterface.php
index 53a66c1..16c5d78 100644
--- a/AbstractFactory/Media.php
+++ b/AbstractFactory/MediaInterface.php
@@ -3,12 +3,12 @@
namespace DesignPatterns\AbstractFactory;
/**
- * Interface Media
+ * Interface MediaInterface
*
* This contract is not part of the pattern, in general case, each component
* are not related
*/
-interface Media
+interface MediaInterface
{
/**
diff --git a/AbstractFactory/Picture.php b/AbstractFactory/Picture.php
index 6d9647e..264bfb6 100644
--- a/AbstractFactory/Picture.php
+++ b/AbstractFactory/Picture.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\AbstractFactory;
/**
* Class Picture
*/
-abstract class Picture implements Media
+abstract class Picture implements MediaInterface
{
/**
diff --git a/AbstractFactory/Text.php b/AbstractFactory/Text.php
index a45d7f2..675e6d5 100644
--- a/AbstractFactory/Text.php
+++ b/AbstractFactory/Text.php
@@ -5,7 +5,7 @@ namespace DesignPatterns\AbstractFactory;
/**
* Class Text
*/
-abstract class Text implements Media
+abstract class Text implements MediaInterface
{
/**
* @var string
diff --git a/Adapter/ElecBookAdapter.php b/Adapter/EBookAdapter.php
similarity index 71%
rename from Adapter/ElecBookAdapter.php
rename to Adapter/EBookAdapter.php
index 49670af..c9ff06f 100644
--- a/Adapter/ElecBookAdapter.php
+++ b/Adapter/EBookAdapter.php
@@ -7,20 +7,22 @@
namespace DesignPatterns\Adapter;
/**
- * ElecBookAdapter is an adapter to fit an e-book like a paper book
+ * EBookAdapter is an adapter to fit an e-book like a paper book
*
* This is the adapter here. Notice it implemennts PaperBookInterface,
* therefore you don't have to change the code of the client which using paper book.
*/
-class ElecBookAdapter implements PaperBookInterface
+class EBookAdapter implements PaperBookInterface
{
protected $eBook;
/**
* Notice the constructor, it "wraps" an electronic book
+ *
+ * @param EBookInterface $ebook
*/
- public function __construct(ElecBookInterface $ebook)
+ public function __construct(EBookInterface $ebook)
{
$this->eBook = $ebook;
}
@@ -33,9 +35,11 @@ class ElecBookAdapter implements PaperBookInterface
$this->eBook->pressStart();
}
+ /**
+ * turns pages
+ */
public function turnPage()
{
$this->eBook->pressNext();
}
-
-}
\ No newline at end of file
+}
diff --git a/Adapter/EBookInterface.php b/Adapter/EBookInterface.php
new file mode 100644
index 0000000..aa16221
--- /dev/null
+++ b/Adapter/EBookInterface.php
@@ -0,0 +1,14 @@
+createText('footnotes')
);
- $this->assertContainsOnly('DesignPatterns\AbstractFactory\Media', $article);
+ $this->assertContainsOnly('DesignPatterns\AbstractFactory\MediaInterface', $article);
+
/* this is the time to look at the Builder pattern. This pattern
* helps you to create complex object like that article above with
* a given Abstract Factory
*/
-
}
-
}
\ No newline at end of file