From d9d8a1d51e903ad19663ba1b9e6444751d745015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Thu, 18 Jan 2018 22:16:08 +0100 Subject: [PATCH 01/14] Add squadron provider, update factory to add formatter --- src/Factory.php | 2 +- src/Provider/Squadron.php | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/Provider/Squadron.php diff --git a/src/Factory.php b/src/Factory.php index 7bab5e9..15ec01c 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -11,7 +11,7 @@ class Factory extends FakerFactory * @var array */ protected static $jediProviders = [ - 'Character', 'Droid', 'Movie', 'Planet', 'Species', 'Vehicle', + 'Character', 'Droid', 'Movie', 'Planet', 'Species', 'Squadron', 'Vehicle', ]; /** diff --git a/src/Provider/Squadron.php b/src/Provider/Squadron.php new file mode 100644 index 0000000..7bd886a --- /dev/null +++ b/src/Provider/Squadron.php @@ -0,0 +1,60 @@ +generator->parse(static::randomElement(static::$pilotFormat))); + + return str_replace('~', '#', static::numerify($pilot)); + } + + /** + * @return string + */ + public function squadron(): string + { + return $this->generator->parse(static::randomElement(static::$squadron)); + } + + /** + * @return string + */ + public function rank(): string + { + return $this->generator->parse(static::randomElement(static::$rank)); + } +} From 1f9b0254c13669b5e8f6abdfa7b37036bc0448fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Thu, 18 Jan 2018 22:21:47 +0100 Subject: [PATCH 02/14] Add primitive tests --- tests/Provider/SquadronTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/Provider/SquadronTest.php diff --git a/tests/Provider/SquadronTest.php b/tests/Provider/SquadronTest.php new file mode 100644 index 0000000..875aa2c --- /dev/null +++ b/tests/Provider/SquadronTest.php @@ -0,0 +1,27 @@ +assertNotNull($faker->squadron); + } + + public function testPilotIsNotNull() + { + $faker = Factory::create(); + $this->assertNotNull($faker->pilot); + } + + public function testRankIsNotNull() + { + $faker = Factory::create(); + $this->assertNotNull($faker->rank); + } +} From b887fe7833b93a6d60d1faedd7b24eec9d2f5004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sat, 20 Jan 2018 20:56:07 +0100 Subject: [PATCH 03/14] Add new squadron names --- src/Provider/Squadron.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Provider/Squadron.php b/src/Provider/Squadron.php index 7bd886a..deabfbc 100644 --- a/src/Provider/Squadron.php +++ b/src/Provider/Squadron.php @@ -17,9 +17,18 @@ class Squadron extends Base * @var array */ protected static $squadron = [ - 'Blue', - 'Green', 'Gold', - 'Red', + 'Black', 'Blade', 'Blue', + 'Corona', 'Cyan', + 'Danger', 'Dust', + 'Exeter', + 'Gray', 'Green', 'Gold', + 'Havoc', + 'Nomad', + 'Phoenix', + 'Rascal', 'Red', 'Rogue', + 'Scavenger', 'Stealth', + 'Wolf', + 'Yellow', ]; /** From 6bf278c43ba7dc4063f6668398611d122dcae0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sat, 20 Jan 2018 21:10:07 +0100 Subject: [PATCH 04/14] Update 'Squadron' word in squadron name generation --- src/Provider/Squadron.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Provider/Squadron.php b/src/Provider/Squadron.php index deabfbc..da7e911 100644 --- a/src/Provider/Squadron.php +++ b/src/Provider/Squadron.php @@ -13,6 +13,11 @@ class Squadron extends Base '{{squadron}} {{rank}}' ]; + /** + * @var string + */ + protected static $squadronWord = 'Squadron'; + /** * @var array */ @@ -56,7 +61,11 @@ public function pilot(): string */ public function squadron(): string { - return $this->generator->parse(static::randomElement(static::$squadron)); + return sprintf( + '%s %s', + $this->generator->parse(static::randomElement(static::$squadron)), + static::$squadronWord + ); } /** From 859e656abcb1a950b9a3a361b90669f49f17f9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Sat, 20 Jan 2018 21:10:46 +0100 Subject: [PATCH 05/14] Update readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index c6b3b56..5656241 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,13 @@ $faker->species; // Wookiee $faker->vehicle; // Millennium Falcon ``` +### `HydrefLab\JediFaker\Provider\Squadron` +``` +$faker->pilot; // Red Leader +$faker->squadron; // Blue Squadron +$faker->rank; // Pilot +``` + ## Contributing Contributions are welcome! Please, read [CONTRIBUTING][] for details. From 5cbf01b93f130022f3a67d0f458f2b7c033c1753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Mon, 22 Jan 2018 13:47:37 +0100 Subject: [PATCH 06/14] Add characters from Star Wars Episode VII: The Force Awakens --- src/Provider/Character.php | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Provider/Character.php b/src/Provider/Character.php index 56bb75a..d9fd15a 100644 --- a/src/Provider/Character.php +++ b/src/Provider/Character.php @@ -11,6 +11,7 @@ class Character extends Base */ protected static $darkSide = [ 'Darth Maul', 'Darth Sidious', 'Darth Vader', 'Dooku', + 'Grievous', 'Kylo Ren', 'Snoke', ]; @@ -39,23 +40,29 @@ class Character extends Base * @var array */ protected static $characters = [ - 'Amilyn Holdo', - 'Bail Prestor Organa', 'Boba Fett', 'Bossk', 'Bren Derlin', - 'C-3PO', 'Captain Phasma', 'Chewbacca', 'Crix Madine', + 'Amilyn Holdo', 'Armitage Hux', 'Athgar Heece', + 'Bail Prestor Organa', 'Bala-Tik', 'Bazine Netal', 'Boba Fett', 'Bobbajo', 'Bollie Prindel', 'Bossk', 'Bren Derlin', + 'C-3PO', 'Caluan Ematt', 'Chewbacca', 'Cratinus', 'Crix Madine', 'Crokind Shand', 'Crusher Roodown', + 'Datoo', 'Dopheld Mitaka', + 'Ello Asty', 'Finis Valorum', 'Finn', 'Firmus Piett', - 'Gial Ackbar', 'Grievous', + 'Gial Ackbar', 'Goss Toowers', 'Grummgar', 'Gwellis Bagnoro', 'Han Solo', - 'Jabba the Hutt', 'Jan Dodonna', 'Jango Fett', 'Jar Jar Binks', - 'Kendal Ozzel', - 'Lando Calrissian', 'Lobot', - 'Mas Amedda', 'Maz Kanata', 'Mon Mothma', - 'Nute Gunray', - 'Padmé Amidala', 'Poe Dameron', 'Poggle the Lesser', - 'R2-D2', 'Rune Haako', - 'Sheev Palpatine', 'Shmi Skywalker', 'Sebulba', 'Sly Moore', - 'Taun We', - 'Watto', 'Wedge Antilles', 'Wicket Warrick', 'Wilhuff Tarkin', - 'Zam Wesell', + 'Ilco Munica', 'Infrablue Zedbeddy Coggins', + 'Jabba the Hutt', 'Jan Dodonna', 'Jango Fett', 'Jar Jar Binks', 'Jashco Phurus', 'Jess Pava', + 'Kalonia', 'Kaydel Ko Connix ', 'Kendal Ozzel', 'Korr Sella', + 'Lando Calrissian', 'Lanever Villecham ', 'Lobot', 'Lor San Tekka', + 'Mas Amedda', 'Maz Kanata', 'Mon Mothma', 'Munduri', + 'Nien Nunb', 'Nute Gunray', + 'Padmé Amidala', 'Phasma', 'Poe Dameron', 'Poggle the Lesser', 'Prashee', 'Praster Ommlen', 'Pru Sweevant', + 'R2-D2', 'Razoo Qin-Fee', 'Rune Haako', + 'Sebulba', 'Sheev Palpatine', 'Shmi Skywalker', 'Sidon Ithano', 'Sonsigo', 'Sly Moore', 'Strono Tuggs', 'Sudswater Dillifay Glon', + 'Taslin Brance', 'Taun We', 'Tasu Leech', 'Taybin Ralorsa', 'Temmin Wexley', 'Thanisson', + 'Quiggold', + 'U.O. Statura', 'Ubert Quaril', 'Unamo', 'Unkar Plutt', + 'Vober Dand', 'Volzang Li-Thrull', + 'Watto', 'Wedge Antilles', 'Wicket Warrick', 'Wilhuff Tarkin', 'Wollivan', + 'Zam Wesell', 'Zuvio', ]; /** From 9ad844d645d224abf6095f2079107d8a394b1f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Mon, 22 Jan 2018 13:47:49 +0100 Subject: [PATCH 07/14] Add droids from Star Wars Episode VII: The Force Awakens --- src/Provider/Droid.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Provider/Droid.php b/src/Provider/Droid.php index aaabdcf..f76df47 100644 --- a/src/Provider/Droid.php +++ b/src/Provider/Droid.php @@ -11,11 +11,15 @@ class Droid extends Base */ protected static $droids = [ '2-1B', '4-LOM', '8D8', - 'BB-8', + 'BB-8', 'B-U4D', 'C-3PO', - 'EV-9D9', + 'EGL-21', 'EV-9D9', 'FA-4', + 'GA-97', + 'HURID-327', 'IGG-88', + 'ME-8D9', + 'PZ-4CO', 'R2-D2', 'R2-Q5', 'R5-D4', 'TC-14', ]; From 5d2b292c2fc2e90fa82e519c110d4be94bbbe108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Mon, 22 Jan 2018 20:36:15 +0100 Subject: [PATCH 08/14] Add characters from Star Wars Episode VIII: The Last Jedi --- src/Provider/Character.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Provider/Character.php b/src/Provider/Character.php index d9fd15a..5bcf595 100644 --- a/src/Provider/Character.php +++ b/src/Provider/Character.php @@ -41,23 +41,26 @@ class Character extends Base */ protected static $characters = [ 'Amilyn Holdo', 'Armitage Hux', 'Athgar Heece', - 'Bail Prestor Organa', 'Bala-Tik', 'Bazine Netal', 'Boba Fett', 'Bobbajo', 'Bollie Prindel', 'Bossk', 'Bren Derlin', - 'C-3PO', 'Caluan Ematt', 'Chewbacca', 'Cratinus', 'Crix Madine', 'Crokind Shand', 'Crusher Roodown', - 'Datoo', 'Dopheld Mitaka', - 'Ello Asty', + 'Bail Prestor Organa', 'Bala-Tik', 'Bazine Netal', 'Boba Fett', 'Bobbajo', 'Bollie Prindel', 'Bossk', + 'Bren Derlin', + 'C\'ai Threnalli', 'C-3PO', 'Caluan Ematt', 'Chewbacca', 'Cratinus', 'Crix Madine', 'Crokind Shand', 'Crusher Roodown', + 'Datoo', 'DJ', 'Dopheld Mitaka', + 'Edrison Peavey', 'Ello Asty', 'Finis Valorum', 'Finn', 'Firmus Piett', 'Gial Ackbar', 'Goss Toowers', 'Grummgar', 'Gwellis Bagnoro', 'Han Solo', 'Ilco Munica', 'Infrablue Zedbeddy Coggins', 'Jabba the Hutt', 'Jan Dodonna', 'Jango Fett', 'Jar Jar Binks', 'Jashco Phurus', 'Jess Pava', 'Kalonia', 'Kaydel Ko Connix ', 'Kendal Ozzel', 'Korr Sella', - 'Lando Calrissian', 'Lanever Villecham ', 'Lobot', 'Lor San Tekka', - 'Mas Amedda', 'Maz Kanata', 'Mon Mothma', 'Munduri', + 'Lando Calrissian', 'Lanever Villecham ', 'Larma D\'Acy', 'Lobot', 'Lor San Tekka', + 'Mas Amedda', 'Maz Kanata', 'Moden Canady', 'Mon Mothma', 'Munduri', 'Nien Nunb', 'Nute Gunray', - 'Padmé Amidala', 'Phasma', 'Poe Dameron', 'Poggle the Lesser', 'Prashee', 'Praster Ommlen', 'Pru Sweevant', - 'R2-D2', 'Razoo Qin-Fee', 'Rune Haako', - 'Sebulba', 'Sheev Palpatine', 'Shmi Skywalker', 'Sidon Ithano', 'Sonsigo', 'Sly Moore', 'Strono Tuggs', 'Sudswater Dillifay Glon', - 'Taslin Brance', 'Taun We', 'Tasu Leech', 'Taybin Ralorsa', 'Temmin Wexley', 'Thanisson', + 'Padmé Amidala', 'Paige Tico', 'Phasma', 'Poe Dameron', 'Poggle the Lesser', 'Prashee', 'Praster Ommlen', 'Pru Sweevant', + 'R2-D2', 'Razoo Qin-Fee', 'Rose Tico', 'Rune Haako', + 'Sebulba', 'Sheev Palpatine', 'Shmi Skywalker', 'Sidon Ithano', 'Sonsigo', 'Slowen Lo', 'Sly Moore', 'Strono Tuggs', + 'Sudswater Dillifay Glon', + 'Tallissan Lintra', 'Taslin Brance', 'Taun We', 'Tasu Leech', 'Taybin Ralorsa', 'Temiri Blagg', 'Temmin Wexley', + 'Thanisson', 'Quiggold', 'U.O. Statura', 'Ubert Quaril', 'Unamo', 'Unkar Plutt', 'Vober Dand', 'Volzang Li-Thrull', From f3e79a6a2cf0bdd31c5dad5d21863925bab01167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Mon, 22 Jan 2018 20:36:27 +0100 Subject: [PATCH 09/14] Add droids from Star Wars Episode VIII: The Last Jedi --- src/Provider/Droid.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Provider/Droid.php b/src/Provider/Droid.php index f76df47..b116b26 100644 --- a/src/Provider/Droid.php +++ b/src/Provider/Droid.php @@ -11,7 +11,7 @@ class Droid extends Base */ protected static $droids = [ '2-1B', '4-LOM', '8D8', - 'BB-8', 'B-U4D', + 'BB-8', 'BB-9E', 'B-U4D', 'C-3PO', 'EGL-21', 'EV-9D9', 'FA-4', @@ -21,6 +21,7 @@ class Droid extends Base 'ME-8D9', 'PZ-4CO', 'R2-D2', 'R2-Q5', 'R5-D4', + 'SE8', 'TC-14', ]; From e5381d84f3a722d3b74cb8d1e70b99e67170e89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Mon, 22 Jan 2018 20:37:13 +0100 Subject: [PATCH 10/14] Add planets, species and squadrons from Star Wars Episode VIII: The Last Jedi --- src/Provider/Planet.php | 2 +- src/Provider/Species.php | 2 +- src/Provider/Squadron.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Provider/Planet.php b/src/Provider/Planet.php index af20e0a..f28b998 100644 --- a/src/Provider/Planet.php +++ b/src/Provider/Planet.php @@ -12,7 +12,7 @@ class Planet extends Base protected static $planets = [ 'Ahch-To', 'Alderaan', 'Bespin', - 'Cantonica', 'Cato Neimoidia', 'Coruscant', + 'Cantonica', 'Cato Neimoidia', 'Coruscant', 'Crait', 'D\'Qar', 'Dagobah', 'Endor', 'Felucia', diff --git a/src/Provider/Species.php b/src/Provider/Species.php index 0aacde5..cf72d07 100644 --- a/src/Provider/Species.php +++ b/src/Provider/Species.php @@ -24,7 +24,7 @@ class Species extends Base 'Luggabeast', 'Mirialan', 'Mon Calamari', 'Nautolan', 'Neimoidian', 'Nikto', - 'Pantoran', 'Pau\'an', + 'Pantoran', 'Pau\'an', 'Porg', 'Quarren', 'Rodian', 'Saurin', 'Sullustan', diff --git a/src/Provider/Squadron.php b/src/Provider/Squadron.php index da7e911..2de1061 100644 --- a/src/Provider/Squadron.php +++ b/src/Provider/Squadron.php @@ -23,7 +23,7 @@ class Squadron extends Base */ protected static $squadron = [ 'Black', 'Blade', 'Blue', - 'Corona', 'Cyan', + 'Cobalt', 'Corona', 'Cyan', 'Danger', 'Dust', 'Exeter', 'Gray', 'Green', 'Gold', From eb401bc60805e10c6e47fcdadf0d9b3a2d7bac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Tue, 23 Jan 2018 20:22:09 +0100 Subject: [PATCH 11/14] Update 'pilot' method, add 'squadronName' method, rename 'rank' method into 'pilotRank' --- src/Provider/Squadron.php | 43 +++++++++++++++++++++------------ tests/Provider/SquadronTest.php | 14 ++++++++++- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/src/Provider/Squadron.php b/src/Provider/Squadron.php index 2de1061..834fa26 100644 --- a/src/Provider/Squadron.php +++ b/src/Provider/Squadron.php @@ -10,7 +10,7 @@ class Squadron extends Base * @var array */ protected static $pilotFormat = [ - '{{squadron}} {{rank}}' + '{{squadron}} {{pilotRank}}' ]; /** @@ -39,40 +39,51 @@ class Squadron extends Base /** * @var array */ - protected static $rank = [ + protected static $pilotRank = [ 'Leader', 'Pilot', ]; /** * @return string */ - public function pilot(): string + public function squadron(): string { - // Replace generated 'Pilot' word with '~#' in order to use numerify function, - // then replace '~' with '#' to have results such as 'Gold #7'. - - $pilot = str_replace('Pilot', '~#', $this->generator->parse(static::randomElement(static::$pilotFormat))); + return $this->generator->parse(static::randomElement(static::$squadron)); + } - return str_replace('~', '#', static::numerify($pilot)); + /** + * @return string + */ + public function squadronName(): string + { + return $this->generator->parse(static::randomElement(static::squadronFormat())); } /** * @return string */ - public function squadron(): string + public function pilot(): string { - return sprintf( - '%s %s', - $this->generator->parse(static::randomElement(static::$squadron)), - static::$squadronWord - ); + $pilot = $this->generator->parse(static::randomElement(static::$pilotFormat)); + + return false !== strpos($pilot, 'Pilot') + ? str_replace('Pilot', '#' . static::numberBetween(1, 12), $pilot) + : $pilot; } /** * @return string */ - public function rank(): string + public function pilotRank(): string + { + return $this->generator->parse(static::randomElement(static::$pilotRank)); + } + + /** + * @return array + */ + protected static function squadronFormat(): array { - return $this->generator->parse(static::randomElement(static::$rank)); + return ['{{squadron}} ' . static::$squadronWord]; } } diff --git a/tests/Provider/SquadronTest.php b/tests/Provider/SquadronTest.php index 875aa2c..516e1fa 100644 --- a/tests/Provider/SquadronTest.php +++ b/tests/Provider/SquadronTest.php @@ -13,6 +13,18 @@ public function testSquadronIsNotNull() $this->assertNotNull($faker->squadron); } + public function testSquadronNameContainsSquadronWord() + { + $faker = Factory::create(); + $this->assertContains('Squadron', $faker->squadronName); + } + + public function testSquadronDoesNotContainSquadronWord() + { + $faker = Factory::create(); + $this->assertNotContains('Squadron', $faker->squadron); + } + public function testPilotIsNotNull() { $faker = Factory::create(); @@ -22,6 +34,6 @@ public function testPilotIsNotNull() public function testRankIsNotNull() { $faker = Factory::create(); - $this->assertNotNull($faker->rank); + $this->assertNotNull($faker->pilotRank); } } From d7351abd9f31e53a7f471d40778e2cdbe5cd54b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Tue, 23 Jan 2018 20:22:38 +0100 Subject: [PATCH 12/14] Lower the probability of generating squadron leader --- src/Provider/Squadron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Provider/Squadron.php b/src/Provider/Squadron.php index 834fa26..6370e05 100644 --- a/src/Provider/Squadron.php +++ b/src/Provider/Squadron.php @@ -40,7 +40,7 @@ class Squadron extends Base * @var array */ protected static $pilotRank = [ - 'Leader', 'Pilot', + 'Leader', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', 'Pilot', ]; /** From 5bcfc3e39b9ae7a991b69077c87a2cc7284910ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Tue, 23 Jan 2018 20:28:41 +0100 Subject: [PATCH 13/14] Update readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5656241..21cc474 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,10 @@ $faker->vehicle; // Millennium Falcon ### `HydrefLab\JediFaker\Provider\Squadron` ``` -$faker->pilot; // Red Leader -$faker->squadron; // Blue Squadron -$faker->rank; // Pilot +$faker->squadron; // Green +$faker->squadronName; // Blue Squadron +$faker->pilot; // Red Leader or Blue #7 +$faker->pilotRank; // Pilot ``` ## Contributing From 125695d8a142e1843925c1e8bf7b67b82b30f332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Golon?= Date: Tue, 23 Jan 2018 20:38:00 +0100 Subject: [PATCH 14/14] Update changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84c3038..b9f28cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,10 @@ * Decreased required PHP version ### Fixed -* Fixed `IGG-88` droid name \ No newline at end of file +* Fixed `IGG-88` droid name + +## v1.2.0 (23-01-2018) + +### Added +* Added new characters, droids, planets and species from Episode VII and Episode VIII +* Added new squadron formatter \ No newline at end of file