From de28ff9faeef004ae39ab397c1577c043701a98f Mon Sep 17 00:00:00 2001 From: Mohammed S Shurrab Date: Mon, 20 Jul 2020 20:27:26 +0300 Subject: [PATCH] refactor shouldGenerate using collection --- src/Blueprint.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Blueprint.php b/src/Blueprint.php index 613770fd..80b82b49 100644 --- a/src/Blueprint.php +++ b/src/Blueprint.php @@ -112,21 +112,11 @@ public function swapGenerator(string $concrete, Generator $generator) protected function shouldGenerate(array $types, array $only, array $skip): bool { if (count($only)) { - $found = 0; - foreach ($types as $type) { - $found += in_array($type, $only) ? 1 : 0; - } - - return $found > 0; + return collect($types)->intersect($only)->isNotEmpty(); } if (count($skip)) { - $found = 0; - foreach ($types as $type) { - $found += in_array($type, $skip) ? 1 : 0; - } - - return $found === 0; + return collect($types)->intersect($skip)->isEmpty(); } return true;