Artist is allowed to be null.
authorCameron Ball <c.ball1729@gmail.com>
Mon, 22 Dec 2014 11:11:09 +0000 (19:11 +0800)
committerCameron Ball <c.ball1729@gmail.com>
Mon, 22 Dec 2014 11:11:09 +0000 (19:11 +0800)
Domain/Entities/StepMania/Simfile.php
Domain/Entities/StepMania/SimfileBuilder.php
Domain/Entities/StepMania/SimfileFactory.php
Domain/Entities/StepMania/SimfileStepByStepBuilder.php
Domain/VOs/StepMania/Difficulty.php
Services/SimfileParser.php
Services/ZipParser.php

index 7071e0b..9a62740 100644 (file)
@@ -29,7 +29,7 @@ class Simfile extends AbstractEntity implements ISimfile
     \r
     public function __construct(\r
         $title,\r
-        IArtist $artist,\r
+        IArtist $artist = null,\r
         IUser $uploader,\r
         IBPM $bpm,\r
         $bpmChanges,\r
index 6c87aa9..e70dabc 100644 (file)
@@ -36,7 +36,7 @@ class SimfileBuilder implements ISimfileBuilder
         return $this;\r
     }\r
     \r
-    public function With_Artist(IArtist $artist) {\r
+    public function With_Artist(IArtist $artist = null) {\r
         $this->_artist = $artist;\r
         return $this;\r
     }\r
index eda0ea3..71a0dbc 100644 (file)
@@ -12,7 +12,7 @@ interface ISimfileFactory
 {\r
     public function createInstance(\r
         $title,\r
-        IArtist $artist,\r
+        IArtist $artist = null,\r
         IUser $uploader,\r
         IBPM $bpm,\r
         $bpmChanges,\r
@@ -30,7 +30,7 @@ class SimfileFactory implements ISimfileFactory
 {\r
     public function createInstance(\r
         $title,\r
-        IArtist $artist,\r
+        IArtist $artist = null,\r
         IUser $uploader,\r
         IBPM $bpm,\r
         $bpmChanges,\r
index 2408d2f..53c7d26 100644 (file)
@@ -15,11 +15,7 @@ interface ISimfileStepByStepBuilder
 \r
 interface ISimfileStepByStepBuilder_With_Title\r
 {\r
-    public function With_Artist(IArtist $artist);\r
-}\r
-\r
-interface ISimfileStepByStepBuilder_With_Artist\r
-{\r
+    public function With_Artist(IArtist $artist = null);\r
     public function With_Uploader(IUser $uploader);\r
 }\r
 \r
@@ -85,15 +81,12 @@ class SimfileStepByStepBuilder extends AbstractSimfileStepByStepBuilder implemen
 \r
 class SimfileStepByStepBuilder_With_Title extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Title\r
 {        \r
-    public function With_Artist(IArtist $artist)\r
+    public function With_Artist(IArtist $artist = null)\r
     {\r
         $this->_simfileBuilder->With_Artist($artist);\r
-        return new SimfileStepByStepBuilder_With_Artist($this->_simfileBuilder);\r
+        return $this;\r
     }\r
-}\r
-\r
-class SimfileStepByStepBuilder_With_Artist extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Artist\r
-{        \r
+    \r
     public function With_Uploader(IUser $uploader)\r
     {\r
         $this->_simfileBuilder->With_Uploader($uploader);\r
index e59578d..a794cc6 100644 (file)
@@ -42,7 +42,7 @@ class Difficulty implements IDifficulty
     );\r
 \r
     public function __construct($name) {\r
-        $ucName = ucfirst($name);\r
+        $ucName = ucfirst(strtolower($name));\r
         if(array_key_exists($ucName, $this->_namesToSmNames)) {\r
             $this->stepManiaName = $this->_namesToSmNames[$ucName];\r
             $this->itgName = $this->_smNamesToItgNames[$this->stepManiaName];\r
index 52608b1..c56dc6d 100644 (file)
@@ -32,7 +32,8 @@ class SimfileParser implements ISimfileParser
     public function artist()
     {
         $artist = $this->extractKey('ARTIST');
-        if(!$artist) throw new Exception ('Invalid SM file. ARTIST missing');
+        //XXX: Artist can be null
+        if(!$artist)return null;
         
         //XXX: UTF8 encode to deal with unusual character that crop up in weeaboo shit.
         return new \Domain\VOs\StepMania\Artist(utf8_encode($artist));
index a669ffc..2fecc25 100644 (file)
@@ -116,7 +116,7 @@ class ZipParser implements IZipParser
                 throw new Exception('Malformed zip. I found more than 1 sm file but the directory structure is not consistent with a pack.');
         }
         
-        return $packName;
+        return utf8_encode($packName);
     }
         
     private function SmDataToSmClass($smData)