File tree Expand file tree Collapse file tree 7 files changed +49
-2
lines changed
Expand file tree Collapse file tree 7 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 11.idea
2+ build
23vendor
34
45.DS_Store
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
77## [ Unreleased]
88
9+ ## [ 1.1.0] - 2020-08-31
10+ ### Added
11+ - ` keyString ` static method to fetch as string, glued by comma by default
12+
913## [ 1.0.1] - 2020-08-30
1014### Fixed
1115- Make ` BaseEnum::$cache ` protected as it was left public.
@@ -14,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1418### Added
1519- Array and illuminate collection implementations
1620
17- [ Unreleased ] : https://github.com/ekvedaras/php-enum/compare/v1.0.1...HEAD
21+ [ Unreleased ] : https://github.com/ekvedaras/php-enum/compare/v1.1.0...HEAD
22+ [ 1.1.0 ] : https://github.com/ekvedaras/php-enum/compare/v1.0.1...v1.1.0
1823[ 1.0.1 ] : https://github.com/ekvedaras/php-enum/compare/v1.0.0...v1.0.1
1924[ 1.0.0 ] : https://github.com/ekvedaras/php-enum/releases/tag/v1.0.0
Original file line number Diff line number Diff line change 4040 "illuminate/support" : " *"
4141 },
4242 "scripts" : {
43- "test" : " phpunit"
43+ "test" : " phpunit" ,
44+ "cover" : " phpunit --coverage-html=build"
4445 },
4546 "config" : {
4647 "sort-packages" : true
Original file line number Diff line number Diff line change @@ -94,6 +94,12 @@ abstract public static function options();
9494 */
9595 abstract public static function keys ();
9696
97+ /**
98+ * @param string $glue
99+ * @return string
100+ */
101+ abstract public static function keyString (string $ glue = ', ' );
102+
97103 /**
98104 * Get enum options with full data as JSON
99105 *
Original file line number Diff line number Diff line change @@ -40,4 +40,12 @@ public static function keys()
4040 {
4141 return static ::enum ()->keys ();
4242 }
43+
44+ /**
45+ * @inheritDoc
46+ */
47+ public static function keyString (string $ glue = ', ' )
48+ {
49+ return static ::keys ()->implode ($ glue );
50+ }
4351}
Original file line number Diff line number Diff line change @@ -64,6 +64,14 @@ public static function keys()
6464 return array_keys (static ::enum ());
6565 }
6666
67+ /**
68+ * @inheritDoc
69+ */
70+ public static function keyString (string $ glue = ', ' )
71+ {
72+ return implode ($ glue , static ::keys ());
73+ }
74+
6775 /**
6876 * @inheritDoc
6977 */
Original file line number Diff line number Diff line change @@ -86,6 +86,24 @@ public function it_fetches_option_list(string $enum)
8686 }
8787 }
8888
89+ /**
90+ * @test
91+ * @dataProvider enums
92+ * @param BaseEnum|PaymentStatusOptions|string $enum
93+ */
94+ public function it_fetches_key_list (string $ enum )
95+ {
96+ $ list = $ enum ::keys ();
97+ $ listString = $ enum ::keyString ($ glue = '; ' );
98+
99+ $ this ->assertCount (count (self ::PAYMENT_STATUS_IDS ), $ list );
100+
101+ foreach (self ::PAYMENT_STATUS_IDS as $ key => $ id ) {
102+ $ this ->assertContains ($ id , $ list );
103+ $ this ->assertStringContainsString ((string )$ id , $ listString );
104+ }
105+ }
106+
89107 /**
90108 * @test
91109 * @dataProvider enums
You can’t perform that action at this time.
0 commit comments