Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit fe6bf22

Browse files
committed
README additions - see README
1 parent cf02800 commit fe6bf22

File tree

1 file changed

+55
-41
lines changed

1 file changed

+55
-41
lines changed

README.md

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ A [Composer](https://getcomposer.org/) package for [PHP](https://www.php.net/) t
1010
The package so far provides;
1111

1212
- A handy trait that extends PHP's native Enum type
13-
- Adds a new static `valueArray(): array` method that returns all values within an Enum as an equally typed array of Enum values
14-
- Adds a new static `valueList(string $separator = ', '): string` method that returns all values within an Enum as a comma separated list string
13+
- Adds a new static `UnitEnum::valueArray(): array` method that returns all values within an Enum as an equally typed array of Enum values
14+
- Adds a new static `UnitEnum::valueList(string $separator = ', '): string` method that returns all values within an Enum as a comma separated list string
1515

1616
The package is available on Packagist as [othyn/php-enum-enhancements](https://packagist.org/packages/othyn/php-enum-enhancements).
1717

@@ -51,17 +51,21 @@ enum TestEnum
5151
case Echo;
5252
}
5353

54-
print_r(TestEnum::valueArray());
54+
var_dump(TestEnum::valueArray());
5555

5656
// Results in the following being printed:
57-
// Array
58-
// (
59-
// [0] => Alpha
60-
// [1] => Bravo
61-
// [2] => Charlie
62-
// [3] => Delta
63-
// [4] => Echo
64-
// )
57+
// array(5) {
58+
// [0]=>
59+
// string(5) "Alpha"
60+
// [1]=>
61+
// string(5) "Bravo"
62+
// [2]=>
63+
// string(7) "Charlie"
64+
// [3]=>
65+
// string(5) "Delta"
66+
// [4]=>
67+
// string(4) "Echo"
68+
// }
6569
```
6670

6771
### Enum: Value List
@@ -84,15 +88,15 @@ enum TestEnum
8488
case Echo;
8589
}
8690

87-
print_r(TestEnum::valueList());
91+
var_dump(TestEnum::valueList());
8892

8993
// Results in the following being printed:
90-
// 'Alpha, Bravo, Charlie, Delta, Echo'
94+
// string(34) "Alpha, Bravo, Charlie, Delta, Echo"
9195

92-
print_r(TestEnum::valueList(separator: ':'));
96+
var_dump(TestEnum::valueList(separator: ':'));
9397

9498
// Results in the following being printed:
95-
// 'Alpha:Bravo:Charlie:Delta:Echo'
99+
// string(30) "Alpha:Bravo:Charlie:Delta:Echo"
96100
```
97101

98102
### Backed String Enum: Value Array
@@ -115,17 +119,21 @@ enum TestStringBackedEnum: string
115119
case Echo = 'echo';
116120
}
117121

118-
print_r(TestStringBackedEnum::valueArray());
122+
var_dump(TestStringBackedEnum::valueArray());
119123

120124
// Results in the following being printed:
121-
// Array
122-
// (
123-
// [0] => alpha
124-
// [1] => bravo
125-
// [2] => charlie
126-
// [3] => delta
127-
// [4] => echo
128-
// )
125+
// array(5) {
126+
// [0]=>
127+
// string(5) "alpha"
128+
// [1]=>
129+
// string(5) "bravo"
130+
// [2]=>
131+
// string(7) "charlie"
132+
// [3]=>
133+
// string(5) "delta"
134+
// [4]=>
135+
// string(4) "echo"
136+
// }
129137
```
130138

131139
### Backed String Enum: Value List
@@ -148,15 +156,15 @@ enum TestStringBackedEnum: string
148156
case Echo = 'echo';
149157
}
150158

151-
print_r(TestStringBackedEnum::valueList());
159+
var_dump(TestStringBackedEnum::valueList());
152160

153161
// Results in the following being printed:
154-
// 'alpha, bravo, charlie, delta, echo'
162+
// string(34) "alpha, bravo, charlie, delta, echo"
155163

156-
print_r(TestStringBackedEnum::valueList(separator: ':'));
164+
var_dump(TestStringBackedEnum::valueList(separator: ':'));
157165

158166
// Results in the following being printed:
159-
// 'alpha:bravo:charlie:delta:echo'
167+
// string(30) "alpha:bravo:charlie:delta:echo"
160168
```
161169

162170
### Backed Int Enum: Value Array
@@ -179,17 +187,21 @@ enum TestIntBackedEnum: int
179187
case Five = 5;
180188
}
181189

182-
print_r(TestIntBackedEnum::valueArray());
190+
var_dump(TestIntBackedEnum::valueArray());
183191

184192
// Results in the following being printed:
185-
// Array
186-
// (
187-
// [0] => 1
188-
// [1] => 2
189-
// [2] => 3
190-
// [3] => 4
191-
// [4] => 5
192-
// )
193+
// array(5) {
194+
// [0]=>
195+
// int(1)
196+
// [1]=>
197+
// int(2)
198+
// [2]=>
199+
// int(3)
200+
// [3]=>
201+
// int(4)
202+
// [4]=>
203+
// int(5)
204+
// }
193205
```
194206

195207
### Backed Int Enum: Value List
@@ -212,15 +224,15 @@ enum TestIntBackedEnum: int
212224
case Five = 5;
213225
}
214226

215-
print_r(TestIntBackedEnum::valueList());
227+
var_dump(TestIntBackedEnum::valueList());
216228

217229
// Results in the following being printed:
218-
// '1, 2, 3, 4, 5'
230+
// string(13) "1, 2, 3, 4, 5"
219231

220-
print_r(TestIntBackedEnum::valueList(separator: ':'));
232+
var_dump(TestIntBackedEnum::valueList(separator: ':'));
221233

222234
// Results in the following being printed:
223-
// '1:2:3:4:5'
235+
// string(9) "1:2:3:4:5"
224236
```
225237

226238
---
@@ -290,6 +302,8 @@ Any and all project changes for releases should be documented below. Versioning
290302
#### Changed
291303

292304
- SemVer verbiage and link change in the README.
305+
- Change usage examples in the readme to instead utilise `var_dump` to demonstrate the resulting types within the array returned from `UnitEnum::valueArray()`.
306+
- Utilised the `UnitEnum` base type within the docs in code examples where a test Enum is not present.
293307

294308
#### Fixed
295309

0 commit comments

Comments
 (0)