public function generate(Books $books) { $tmpBook = $books->duplicate(); $groupOfBooks = []; do { $numbers = $tmpBook->names(); $unique = array_keys(array_unique($numbers)); $groupOfBooks[] = $tmpBook->remove($unique); } while ($tmpBook->hasBooks()); return [new BooksGroup($groupOfBooks)]; }
private function hasFiveDifferentBooks(Books $books) { $bookNames = $books->names(); return count(array_unique($bookNames)) == 5; }