From c017fc9a290be5a40f9616974e29855fb6f7a644 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Mon, 22 Dec 2014 19:11:09 +0800 Subject: [PATCH] Artist is allowed to be null. --- Domain/Entities/StepMania/Simfile.php | 2 +- Domain/Entities/StepMania/SimfileBuilder.php | 2 +- Domain/Entities/StepMania/SimfileFactory.php | 4 ++-- Domain/Entities/StepMania/SimfileStepByStepBuilder.php | 15 ++++----------- Domain/VOs/StepMania/Difficulty.php | 2 +- Services/SimfileParser.php | 3 ++- Services/ZipParser.php | 2 +- 7 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Domain/Entities/StepMania/Simfile.php b/Domain/Entities/StepMania/Simfile.php index 7071e0b..9a62740 100644 --- a/Domain/Entities/StepMania/Simfile.php +++ b/Domain/Entities/StepMania/Simfile.php @@ -29,7 +29,7 @@ class Simfile extends AbstractEntity implements ISimfile public function __construct( $title, - IArtist $artist, + IArtist $artist = null, IUser $uploader, IBPM $bpm, $bpmChanges, diff --git a/Domain/Entities/StepMania/SimfileBuilder.php b/Domain/Entities/StepMania/SimfileBuilder.php index 6c87aa9..e70dabc 100644 --- a/Domain/Entities/StepMania/SimfileBuilder.php +++ b/Domain/Entities/StepMania/SimfileBuilder.php @@ -36,7 +36,7 @@ class SimfileBuilder implements ISimfileBuilder return $this; } - public function With_Artist(IArtist $artist) { + public function With_Artist(IArtist $artist = null) { $this->_artist = $artist; return $this; } diff --git a/Domain/Entities/StepMania/SimfileFactory.php b/Domain/Entities/StepMania/SimfileFactory.php index eda0ea3..71a0dbc 100644 --- a/Domain/Entities/StepMania/SimfileFactory.php +++ b/Domain/Entities/StepMania/SimfileFactory.php @@ -12,7 +12,7 @@ interface ISimfileFactory { public function createInstance( $title, - IArtist $artist, + IArtist $artist = null, IUser $uploader, IBPM $bpm, $bpmChanges, @@ -30,7 +30,7 @@ class SimfileFactory implements ISimfileFactory { public function createInstance( $title, - IArtist $artist, + IArtist $artist = null, IUser $uploader, IBPM $bpm, $bpmChanges, diff --git a/Domain/Entities/StepMania/SimfileStepByStepBuilder.php b/Domain/Entities/StepMania/SimfileStepByStepBuilder.php index 2408d2f..53c7d26 100644 --- a/Domain/Entities/StepMania/SimfileStepByStepBuilder.php +++ b/Domain/Entities/StepMania/SimfileStepByStepBuilder.php @@ -15,11 +15,7 @@ interface ISimfileStepByStepBuilder interface ISimfileStepByStepBuilder_With_Title { - public function With_Artist(IArtist $artist); -} - -interface ISimfileStepByStepBuilder_With_Artist -{ + public function With_Artist(IArtist $artist = null); public function With_Uploader(IUser $uploader); } @@ -85,15 +81,12 @@ class SimfileStepByStepBuilder extends AbstractSimfileStepByStepBuilder implemen class SimfileStepByStepBuilder_With_Title extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Title { - public function With_Artist(IArtist $artist) + public function With_Artist(IArtist $artist = null) { $this->_simfileBuilder->With_Artist($artist); - return new SimfileStepByStepBuilder_With_Artist($this->_simfileBuilder); + return $this; } -} - -class SimfileStepByStepBuilder_With_Artist extends AbstractSimfileStepByStepBuilder implements ISimfileStepByStepBuilder_With_Artist -{ + public function With_Uploader(IUser $uploader) { $this->_simfileBuilder->With_Uploader($uploader); diff --git a/Domain/VOs/StepMania/Difficulty.php b/Domain/VOs/StepMania/Difficulty.php index e59578d..a794cc6 100644 --- a/Domain/VOs/StepMania/Difficulty.php +++ b/Domain/VOs/StepMania/Difficulty.php @@ -42,7 +42,7 @@ class Difficulty implements IDifficulty ); public function __construct($name) { - $ucName = ucfirst($name); + $ucName = ucfirst(strtolower($name)); if(array_key_exists($ucName, $this->_namesToSmNames)) { $this->stepManiaName = $this->_namesToSmNames[$ucName]; $this->itgName = $this->_smNamesToItgNames[$this->stepManiaName]; diff --git a/Services/SimfileParser.php b/Services/SimfileParser.php index 52608b1..c56dc6d 100644 --- a/Services/SimfileParser.php +++ b/Services/SimfileParser.php @@ -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)); diff --git a/Services/ZipParser.php b/Services/ZipParser.php index a669ffc..2fecc25 100644 --- a/Services/ZipParser.php +++ b/Services/ZipParser.php @@ -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) -- 2.11.0