From 7d062c385b2bd63678f541505f812420daca6643 Mon Sep 17 00:00:00 2001 From: Romain Lanz Date: Thu, 26 Feb 2015 21:35:47 +0100 Subject: [PATCH 1/2] Removing dot at the end of the sentence If we want to stay on Laravel command's description we need to remove this dot. --- src/Commands/PivotMigrationMakeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/PivotMigrationMakeCommand.php b/src/Commands/PivotMigrationMakeCommand.php index b9d498a..f4a2431 100644 --- a/src/Commands/PivotMigrationMakeCommand.php +++ b/src/Commands/PivotMigrationMakeCommand.php @@ -21,7 +21,7 @@ class PivotMigrationMakeCommand extends GeneratorCommand * * @var string */ - protected $description = 'Create a new migration pivot class.'; + protected $description = 'Create a new migration pivot class'; /** * The type of class being generated. From b5dc81f9637b8b8a32701c41278bc0f2156f9be7 Mon Sep 17 00:00:00 2001 From: Brandon Surowiec Date: Sat, 28 Feb 2015 01:10:08 -0500 Subject: [PATCH 2/2] Parse schema with multiple fields, and no spaces --- spec/Migrations/SchemaParserSpec.php | 16 ++++++++++++++++ src/Migrations/SchemaParser.php | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/Migrations/SchemaParserSpec.php b/spec/Migrations/SchemaParserSpec.php index 6d1bac4..13cf0c0 100644 --- a/spec/Migrations/SchemaParserSpec.php +++ b/spec/Migrations/SchemaParserSpec.php @@ -40,4 +40,20 @@ function it_parses_correctly_when_the_type_contains_method_arguments() ['name' => 'amount', 'type' => 'decimal', 'arguments' => ['5', '2'], 'options' => []] ]); } + + function it_parses_schema_with_multiple_fields_using_no_spaces() + { + $this->parse('name:string,age:integer')->shouldReturn([ + ['name' => 'name', 'type' => 'string', 'arguments' => [], 'options' => []], + ['name' => 'age', 'type' => 'integer', 'arguments' => [], 'options' => []], + ]); + } + + function it_parses_schema_with_multiple_fields_containing_arguments_using_no_spaces() + { + $this->parse('name:string,amount:decimal(5,2)')->shouldReturn([ + ['name' => 'name', 'type' => 'string', 'arguments' => [], 'options' => []], + ['name' => 'amount', 'type' => 'decimal', 'arguments' => ['5', '2'], 'options' => []] + ]); + } } diff --git a/src/Migrations/SchemaParser.php b/src/Migrations/SchemaParser.php index 6b52e8d..00d493b 100644 --- a/src/Migrations/SchemaParser.php +++ b/src/Migrations/SchemaParser.php @@ -34,7 +34,9 @@ public function parse($schema) */ private function getFields($schema) { - return preg_split('/\s?,\s/', $schema); + $preg_split = preg_split('/,(?![^()]*+\\))/', $schema); + + return array_map("trim", $preg_split); } /**