Pack entity builder stuff. Not tested yet.
authorCameron Ball <cameron@getapproved.com.au>
Tue, 18 Nov 2014 08:46:39 +0000 (16:46 +0800)
committerCameron Ball <cameron@getapproved.com.au>
Tue, 18 Nov 2014 08:46:39 +0000 (16:46 +0800)
Domain/Entities/StepMania/IPackBuilder.php [new file with mode: 0644]
Domain/Entities/StepMania/Pack.php
Domain/Entities/StepMania/PackBuilder.php [new file with mode: 0644]
Domain/Entities/StepMania/PackFactory.php [new file with mode: 0644]
Domain/Entities/StepMania/PackStepByStepBuilder.php [new file with mode: 0644]
Domain/Entities/StepMania/SimfileBuilder.php
Domain/Entities/StepMania/SimfileStepByStepBuilder.php

diff --git a/Domain/Entities/StepMania/IPackBuilder.php b/Domain/Entities/StepMania/IPackBuilder.php
new file mode 100644 (file)
index 0000000..10e5d6d
--- /dev/null
@@ -0,0 +1,15 @@
+<?php
+
+namespace Domain\Entities\StepMania;
+
+use Domain\Entities\IUser;
+use Domain\Entities\IFile;
+
+interface IPackBuilder
+{
+    public function With_Title($title);
+    public function With_Uploader(IUser $uploader);
+    public function With_Simfiles(array $simfiles);
+    public function With_File(IFile $file);
+    public function build();
+}
\ No newline at end of file
index b58ca12..970c8df 100644 (file)
@@ -20,8 +20,8 @@ class Pack extends AbstractEntity implements IPack
         $title,
         IUser $uploader,
         array $simfiles,
-        IFile $file = null)
-    {
+        IFile $file = null
+    {
         $this->_title = $title;
         $this->_uploader = $uploader;
         $this->_file = $file;
diff --git a/Domain/Entities/StepMania/PackBuilder.php b/Domain/Entities/StepMania/PackBuilder.php
new file mode 100644 (file)
index 0000000..e9f1099
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+namespace Domain\Entities\StepMania;
+
+use Domain\Entities\IUser;
+use Domain\Entities\IFile;
+use Domain\Entities\StepMania\IPackFactory;
+use Domain\Entities\StepMania\IPackBuilder;
+
+class PackBuilder implements IPackBuilder
+{    
+    
+    private $_packFactory;
+    private $_title;
+    private $_uploader;
+    private $_simfiles;
+    private $_file;
+    
+    //override parent
+    public function __construct(IPackFactory $packFactory)
+    {
+        $this->_packFactory = $packFactory;
+    }
+    
+    public function With_Title($title)
+    {
+        $this->_title = $title;
+        return $this;
+    }
+    
+    public function With_File(IFile $file)
+    {
+        $this->_file = $file;
+        return $this;
+    }
+    
+    public function With_Simfiles(array $simfiles)
+    {
+        $this->_simfiles = $simfiles;
+        return $this;
+    }
+    
+    public function With_Uploader(IUser $uploader)
+    {
+        $this->_uploader = $uploader;
+        return $this;
+    }
+    
+    public function build()
+    {
+        return $this->_packFactory->createInstance($this->_title,
+                                                   $this->_uploader,
+                                                   $this->_simfiles);
+    }
+}
\ No newline at end of file
diff --git a/Domain/Entities/StepMania/PackFactory.php b/Domain/Entities/StepMania/PackFactory.php
new file mode 100644 (file)
index 0000000..6723466
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Domain\Entities\StepMania;
+
+use Domain\Entities\StepMania\Pack;
+use Domain\Entities\IUser;
+
+interface IPackFactory
+{
+    public function createInstance(
+        $title,
+        IUser $uploader,
+        array $simfiles,
+        IFile $file = null
+    );
+}
+
+class PackFactory implements IPackFactory
+{
+    public function createInstance(
+        $title,
+        IUser $uploader,
+        array $simfiles,
+        IFile $file = null
+    ) {
+        return new Pack(
+            $title,
+            $uploader,
+            $simfiles,
+            $file
+        );
+    }
+}
diff --git a/Domain/Entities/StepMania/PackStepByStepBuilder.php b/Domain/Entities/StepMania/PackStepByStepBuilder.php
new file mode 100644 (file)
index 0000000..89261b3
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+namespace Domain\Entities\StepMania;
+
+use Domain\Entities\StepMania\IPackBuilder;
+use Domain\Entities\IUser;
+use Domain\Entities\IFile;
+
+interface IPackStepByStepBuilder
+{
+    public function With_Title($title);
+}
+
+interface IPackStepByStepBuilder_With_Title
+{
+    public function With_Uploader(IUser $user);
+}
+
+interface IPackStepByStepBuilder_With_Uploader
+{
+    public function With_Simfiles(array $simfiles);
+}
+
+interface IPackStepByStepBuilder_With_Simfiles
+{
+    public function With_File(IFile $file);
+    public function build();
+}
+
+abstract class AbstractPackStepByStepBuilder
+{
+    /* @var $_simfileBuilder Domain\Entities\StepMania\ISimfileBuilder */
+    protected $_packBuilder;
+    
+    public function __construct(IPackBuilder $builder)
+    {
+        $this->_packBuilder = $builder;
+    }
+}
+
+
+class PackStepByStepBuilder extends AbstractPackStepByStepBuilder implements IPackStepByStepBuilder
+{
+    public function With_Title($title)
+    {
+        $this->_packBuilder->With_Title($title);
+        return new PackStepByStepBuilder_With_Title($this->_packBuilder);
+    }
+}
+
+class PackStepByStepBuilder_With_Title extends AbstractPackStepByStepBuilder implements IPackStepByStepBuilder_With_Title
+{        
+    public function With_Uploader(IUser $user)
+    {
+        $this->_packBuilder->With_Artist($artist);
+        return new PackStepByStepBuilder_With_Artist($this->_packBuilder);
+    }
+}
+
+class PackStepByStepBuilder_With_Uploader extends AbstractPackStepByStepBuilder implements IPackStepByStepBuilder_With_Uploader
+{
+    public function With_Simfiles(array $simfiles)
+    {
+        $this->_packBuilder->With_Simfiles($simfiles);
+        return new PackStepByStepBuilder_With_Simfiles($this->_packBuilder);
+    }
+}
+
+class PackStepByStepBuilder_With_Simfiles extends AbstractPackStepByStepBuilder implements IPackStepByStepBuilder_With_Simfiles
+{
+    public function With_File(Ifile $file)
+    {
+        $this->_packBuilder->With_File($file);
+    }
+    
+    public function build()
+    {
+        return $this->_simfileBuilder
+                    ->build();
+    }
+}
index bc80945..c8afcd2 100644 (file)
@@ -11,7 +11,6 @@ use Domain\Entities\StepMania\ISimfileBuilder;
 \r
 class SimfileBuilder implements ISimfileBuilder  \r
 {    \r
-    /* var $_simfileFactor Domain\Entities\StepMania\ISimfileFactory */\r
     private $_simfileFactory;\r
     private $_title;\r
     private $_artist;\r
index dfc5cbb..8f03a2f 100644 (file)
@@ -2,7 +2,6 @@
 \r
 namespace Domain\Entities\StepMania;\r
 \r
-use Domain\ConstantsAndTypes\SIMFILE_CONSTANT;\r
 use Domain\VOs\StepMania\IArtist;\r
 use Domain\VOs\StepMania\IBPM;\r
 use Domain\Entities\StepMania\ISimfileBuilder;\r
@@ -21,7 +20,7 @@ interface ISimfileStepByStepBuilder_With_Title
 \r
 interface ISimfileStepByStepBuilder_With_Artist\r
 {\r
-    public function With_Uploader(IUser $uploader); //TODO: Make user object\r
+    public function With_Uploader(IUser $uploader);\r
 }\r
 \r
 interface ISimfileStepByStepBuilder_With_Uploader\r
@@ -76,7 +75,8 @@ abstract class AbstractSimfileStepByStepBuilder
 \r
 class SimfileStepByStepBuilder extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder\r
 {\r
-    public function With_Title($title) {\r
+    public function With_Title($title)\r
+    {\r
         $this->_simfileBuilder->With_Title($title);\r
         return new SimfileStepByStepBuilder_With_Title($this->_simfileBuilder);\r
     }\r
@@ -102,7 +102,8 @@ class SimfileStepByStepBuilder_With_Artist extends AbstractSimfileStepByStepBuil
 \r
 class SimfileStepByStepBuilder_With_Uploader extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Uploader\r
 {\r
-    public function With_BPM(IBPM $bpm) {\r
+    public function With_BPM(IBPM $bpm)\r
+    {\r
         $this->_simfileBuilder->With_BPM($bpm);\r
         return new SimfileStepByStepBuilder_With_BPM($this->_simfileBuilder);\r
     }\r
@@ -110,7 +111,8 @@ class SimfileStepByStepBuilder_With_Uploader extends AbstractSimfileStepByStepBu
 \r
 class SimfileStepByStepBuilder_With_BPM extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_BPM\r
 {\r
-    public function With_BpmChanges($const) {\r
+    public function With_BpmChanges($const)\r
+    {\r
         $this->_simfileBuilder->With_BpmChanges($const);\r
         return new SimfileStepByStepBuilder_With_BpmChanges($this->_simfileBuilder);\r
     }\r
@@ -126,7 +128,8 @@ class SimfileStepByStepBuilder_With_BpmChanges extends AbstractSimfileStepByStep
 \r
 class SimfileStepByStepBuilder_With_Stops extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Stops\r
 {\r
-    public function With_FgChanges($const) {\r
+    public function With_FgChanges($const)\r
+    {\r
         $this->_simfileBuilder->With_FgChanges($const);\r
         return new SimfileStepByStepBuilder_With_FgChanges($this->_simfileBuilder);\r
     }\r
@@ -134,7 +137,8 @@ class SimfileStepByStepBuilder_With_Stops extends AbstractSimfileStepByStepBuild
 \r
 class SimfileStepByStepBuilder_With_FgChanges extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_FgChanges\r
 {\r
-    public function With_BgChanges($const) {\r
+    public function With_BgChanges($const)\r
+    {\r
         $this->_simfileBuilder->With_BgChanges($const);\r
         return new SimfileStepByStepBuilder_With_BgChanges($this->_simfileBuilder);\r
     }\r
@@ -142,7 +146,8 @@ class SimfileStepByStepBuilder_With_FgChanges extends AbstractSimfileStepByStepB
 \r
 class SimfileStepByStepBuilder_With_BgChanges extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_BgChanges\r
 {\r
-    public function With_Steps(array $steps) {\r
+    public function With_Steps(array $steps)\r
+    {\r
         $this->_simfileBuilder->With_Steps($steps);\r
         return new SimfileStepByStepBuilder_With_Steps($this->_simfileBuilder);\r
     }\r
@@ -150,17 +155,20 @@ class SimfileStepByStepBuilder_With_BgChanges extends AbstractSimfileStepByStepB
 \r
 class SimfileStepByStepBuilder_With_Steps extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Steps\r
 {\r
-    public function With_Banner(IFile $banner) {\r
+    public function With_Banner(IFile $banner)\r
+    {\r
         $this->_simfileBuilder->With_Banner($banner);\r
         return new SimfileStepByStepBuilder_With_Steps($this->_simfileBuilder);\r
     }\r
     \r
-    public function With_Simfile(IFile $simfile) {\r
+    public function With_Simfile(IFile $simfile)\r
+    {\r
         $this->_simfileBuilder->With_Simfile($simfile);\r
         return new SimfileStepByStepBuilder_With_Steps($this->_simfileBuilder);\r
     }\r
     \r
-    public function build() {\r
+    public function build()\r
+    {\r
         return $this->_simfileBuilder\r
                     ->build();\r
     }\r