We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7270cce commit 9f13cb7Copy full SHA for 9f13cb7
composer.json
@@ -35,6 +35,7 @@
35
"src/AtLeast.php",
36
"src/AtMost.php",
37
"src/Exactly.php",
38
+ "src/IsEmpty.php",
39
"src/Add.php",
40
"src/Set.php",
41
"src/Pipe.php",
src/IsEmpty.php
@@ -0,0 +1,28 @@
1
+<?php
2
+declare(strict_types=1);
3
+
4
+namespace BrenoRoosevelt;
5
6
+use Throwable;
7
+use Traversable;
8
9
+/**
10
+ * @param array|Traversable $haystack
11
+ * @return bool
12
+ */
13
+function is_empty($haystack): bool
14
+{
15
+ $tmp = $haystack;
16
+ try {
17
+ if (is_object($haystack)) {
18
+ $tmp = clone $haystack;
19
+ }
20
+ } catch (Throwable $exception) {
21
22
23
+ foreach ($tmp as $item) {
24
+ return false;
25
26
27
+ return true;
28
+}
0 commit comments