Skip to content

Commit cc6ad93

Browse files
committed
Convert method to helper function
Additionally, the function was refactored to make use of the splat operator
1 parent 69fa037 commit cc6ad93

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/Detectors/Languages.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace Embed\Detectors;
55

6+
use function Embed\isEmpty;
7+
68
class Languages extends Detector
79
{
810
/**
@@ -17,7 +19,7 @@ public function detect(): array
1719
$language = $node->getAttribute('hreflang');
1820
$href = $node->getAttribute('href');
1921

20-
if (self::isEmpty($language) || self::isEmpty($href)) {
22+
if (isEmpty($language, $href)) {
2123
continue;
2224
}
2325

@@ -26,13 +28,4 @@ public function detect(): array
2628

2729
return $languages;
2830
}
29-
30-
private function isEmpty(string $value): bool
31-
{
32-
$skipValues = array(
33-
'undefined',
34-
);
35-
36-
return empty($value) || in_array($value, $skipValues);
37-
}
3831
}

src/functions.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,18 @@ function getDirectory(string $path, int $position): ?string
132132
$dirs = explode('/', $path);
133133
return $dirs[$position + 1] ?? null;
134134
}
135+
136+
function isEmpty(mixed ...$values): bool
137+
{
138+
$skipValues = array(
139+
'undefined',
140+
);
141+
142+
foreach ($values as $value) {
143+
if (empty($value) || in_array($value, $skipValues)) {
144+
return true;
145+
}
146+
}
147+
148+
return false;
149+
}

0 commit comments

Comments
 (0)