Skip to content

Commit b1dba1b

Browse files
authored
refactor shouldGenerate using collection (#299)
1 parent b826722 commit b1dba1b

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/Blueprint.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,11 @@ public function swapGenerator(string $concrete, Generator $generator)
112112
protected function shouldGenerate(array $types, array $only, array $skip): bool
113113
{
114114
if (count($only)) {
115-
$found = 0;
116-
foreach ($types as $type) {
117-
$found += in_array($type, $only) ? 1 : 0;
118-
}
119-
120-
return $found > 0;
115+
return collect($types)->intersect($only)->isNotEmpty();
121116
}
122117

123118
if (count($skip)) {
124-
$found = 0;
125-
foreach ($types as $type) {
126-
$found += in_array($type, $skip) ? 1 : 0;
127-
}
128-
129-
return $found === 0;
119+
return collect($types)->intersect($skip)->isEmpty();
130120
}
131121

132122
return true;

0 commit comments

Comments
 (0)