From 69aa0ae5b52dd51ba0b85e5fb09fb49bf4b64195 Mon Sep 17 00:00:00 2001 From: Dominik Liebler Date: Fri, 13 Sep 2013 14:34:13 +0200 Subject: [PATCH] cs Prototype --- Prototype/BarBookPrototype.php | 22 ++++++++++++ Prototype/BookPrototype.php | 48 +++++++++++++++++++++++++ Prototype/FooBookPrototype.php | 19 ++++++++++ Prototype/Prototype.php | 65 ---------------------------------- Prototype/index.php | 12 +++++++ 5 files changed, 101 insertions(+), 65 deletions(-) create mode 100644 Prototype/BarBookPrototype.php create mode 100644 Prototype/BookPrototype.php create mode 100644 Prototype/FooBookPrototype.php delete mode 100644 Prototype/Prototype.php create mode 100644 Prototype/index.php diff --git a/Prototype/BarBookPrototype.php b/Prototype/BarBookPrototype.php new file mode 100644 index 0000000..c254496 --- /dev/null +++ b/Prototype/BarBookPrototype.php @@ -0,0 +1,22 @@ +title; + } + + /** + * @param string $title + */ + public function setTitle($title) + { + $this->title = $title; + } +} diff --git a/Prototype/FooBookPrototype.php b/Prototype/FooBookPrototype.php new file mode 100644 index 0000000..ed2f250 --- /dev/null +++ b/Prototype/FooBookPrototype.php @@ -0,0 +1,19 @@ +_title; - } - - public function setTitle($title) - { - $this->_title = $title; - } -} - -class FooBookPrototype extends BookPrototype -{ - protected $_category = 'Foo'; - - public function __clone() - { - - } -} - -class BarBookPrototype extends BookPrototype -{ - protected $_category = 'Bar'; - - - public function __clone() - { - - } -} - -$fooPrototype = new FooBookPrototype(); -$barPrototype = new BarBookPrototype(); - -// now lets say we need 10,000 books of foo and 5,000 of bar ... -for ($i = 0; $i < 10000; $i++) { - $book = clone $fooPrototype; - $book->setTitle('Foo Book No ' . $i); -} diff --git a/Prototype/index.php b/Prototype/index.php new file mode 100644 index 0000000..70e2ac1 --- /dev/null +++ b/Prototype/index.php @@ -0,0 +1,12 @@ +setTitle('Foo Book No ' . $i); +}