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

Commit 1301f13

Browse files
committed
Merge branch 'v1.0.1'
2 parents 23d857f + 45e566c commit 1301f13

File tree

7 files changed

+86
-48
lines changed

7 files changed

+86
-48
lines changed

README.md

+78-42
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
---
@@ -275,7 +287,31 @@ composer docker-shell
275287

276288
## Changelog
277289

278-
Any and all project changes for releases should be documented below. Versioning follows the SEMVER standard.
290+
Any and all project changes for releases should be documented below. Versioning follows the [SemVer](https://semver.org/) standard.
291+
292+
---
293+
294+
### Version 1.0.1
295+
296+
[[Git Changes]](https://github.com/othyn/php-enum-enhancements/compare/v1.0.0...v1.0.1) TBD.
297+
298+
#### Added
299+
300+
- Everything
301+
302+
#### Changed
303+
304+
- 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.
307+
308+
#### Fixed
309+
310+
- Everything
311+
312+
#### Removed
313+
314+
- Nothing
279315

280316
---
281317

test_coverage/html/EnumEnhancements.php.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
<h4>Legend</h4>
184184
<p><span class="success"><strong>Executed</strong></span><span class="danger"><strong>Not Executed</strong></span><span class="warning"><strong>Dead Code</strong></span></p>
185185
<p>
186-
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 9.2.10</a> using <a href="https://secure.php.net/" target="_top">PHP 8.1.2</a> and <a href="https://phpunit.de/">PHPUnit 9.5.13</a> at Tue Feb 15 18:46:59 UTC 2022.</small>
186+
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 9.2.10</a> using <a href="https://secure.php.net/" target="_top">PHP 8.1.2</a> and <a href="https://phpunit.de/">PHPUnit 9.5.13</a> at Tue Feb 15 19:12:57 UTC 2022.</small>
187187
</p>
188188
<a title="Back to the top" id="toplink" href="#">
189189
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="16" viewBox="0 0 12 16"><path fill-rule="evenodd" d="M12 11L6 5l-6 6h12z"/></svg>

test_coverage/html/dashboard.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ <h3>Project Risks</h3>
135135
<footer>
136136
<hr/>
137137
<p>
138-
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 9.2.10</a> using <a href="https://secure.php.net/" target="_top">PHP 8.1.2</a> and <a href="https://phpunit.de/">PHPUnit 9.5.13</a> at Tue Feb 15 18:46:59 UTC 2022.</small>
138+
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 9.2.10</a> using <a href="https://secure.php.net/" target="_top">PHP 8.1.2</a> and <a href="https://phpunit.de/">PHPUnit 9.5.13</a> at Tue Feb 15 19:12:57 UTC 2022.</small>
139139
</p>
140140
</footer>
141141
</div>

test_coverage/html/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h4>Legend</h4>
110110
<span class="success"><strong>High</strong>: 90% to 100%</span>
111111
</p>
112112
<p>
113-
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 9.2.10</a> using <a href="https://secure.php.net/" target="_top">PHP 8.1.2</a> and <a href="https://phpunit.de/">PHPUnit 9.5.13</a> at Tue Feb 15 18:46:59 UTC 2022.</small>
113+
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 9.2.10</a> using <a href="https://secure.php.net/" target="_top">PHP 8.1.2</a> and <a href="https://phpunit.de/">PHPUnit 9.5.13</a> at Tue Feb 15 19:12:57 UTC 2022.</small>
114114
</p>
115115
</footer>
116116
</div>

test_coverage/report.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
Code Coverage Report:
4-
2022-02-15 18:46:59
4+
2022-02-15 19:12:57
55

66
Summary:
77
Classes: 100.00% (1/1)

test_coverage/report.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<coverage generated="1644950819">
3-
<project timestamp="1644950819">
2+
<coverage generated="1644952377">
3+
<project timestamp="1644952377">
44
<file name="/testing/src/Traits/EnumEnhancements.php">
55
<class name="Othyn\PhpEnumEnhancements\Traits\EnumEnhancements" namespace="global">
66
<metrics complexity="3" methods="2" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="4" coveredstatements="4" elements="6" coveredelements="6"/>

tests/Feature/ItExtendsIntBackedEnumsTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function test_it_can_produce_a_value_array_for_an_int_backed_enum(): void
1717

1818
public function test_it_can_produce_a_value_list_for_an_int_backed_enum(): void
1919
{
20+
var_dump(TestIntBackedEnum::valueList());
2021
$this->assertSame(
2122
TestIntBackedEnum::valueList(),
2223
'1, 2, 3, 4, 5'
@@ -25,6 +26,7 @@ public function test_it_can_produce_a_value_list_for_an_int_backed_enum(): void
2526

2627
public function test_it_can_produce_a_value_list_with_a_custom_separator_for_an_enum(): void
2728
{
29+
var_dump(TestIntBackedEnum::valueList(separator: ':'));
2830
$this->assertSame(
2931
TestIntBackedEnum::valueList(separator: ':'),
3032
'1:2:3:4:5'

0 commit comments

Comments
 (0)