Skip to content

Commit

Permalink
Added Laravel comparison doc
Browse files Browse the repository at this point in the history
  • Loading branch information
aadegbam authored and aadegbam committed Dec 6, 2018
1 parent 5f6b93a commit be01461
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions docs/LaravelMethodsEquivalence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
|Laravel 5.7 Collection Methods |Versatile Collection Equivalent(s)
|--- |---
|all |toArray
|average |NumericsCollection::average, `$coll->getAsNewType(\VersatileCollections\NumericsCollection::class)->average();` where `$coll` is an instance of CollectionInterface containing integers and / or floats.
|avg |See NumericsCollection::average above
|chunk |getCollectionsOfSizeN, or iterator_to_array( yieldCollectionsOfSizeN )
|collapse |Not implemented, see spreadsheet for alternative snippet
|combine |Not implemented, see spreadsheet for alternative snippet
|concat |appendCollection() or appendItem() depending on the use case, see spreadsheet for snippet
|contains |no non-strict version for now
|containsStrict |containsItem, containsItems, containsKey, containsKeys & containsItemWithKey
|count |count
|crossJoin |Not implemented, maybe in a later version
|dd |Not implemented, user should choose how to dump collection objects. __toString() & __debugInfo() can be helpful.
|diff |diff, diffUsing
|diffAssoc |diffAssoc, diffAssocUsing
|diffKeys |diffKeys, diffKeysUsing
|dump |Not implemented, user should choose how to dump collection objects. __toString() & __debugInfo() can be helpful.
|each |each
|eachSpread |Not implemented, maybe in a later version
|every |allSatisfyConditions
|except |getAllWhereKeysNotIn
|filter |filterAll & filterFirstN
|first |firstItem & filterFirstN
|firstWhere |filterFirstN
|flatMap |Not implemented, maybe in a later version
|flatten |Not implemented, maybe in a later version
|flip |Not implemented, see spreadsheet for alternative snippet
|forget |removeAll
|forPage |paginate
|get |getIfExists
|groupBy |Not implemented, will be implemented in a later version
|has |containsKey & containsKeys
|implode |Not implemented, will be implemented in a later version
|intersect |intersectByItems, intersectByItemsUsingCallback, intersectByKeysAndItems, intersectByKeysAndItemsUsingCallbacks
|intersectByKeys |intersectByKeys, intersectByKeysAndItems, intersectByKeysAndItemsUsingCallbacks, intersectByKeysUsingCallback
|isEmpty |isEmpty
|isNotEmpty |Will implement soon, for fluency sake
|keyBy |Not Implemented, Does not make sense for ScalarCollection and its sub-classes.
|keys |getKeys
|last |lastItem. Can do $coll->reverse()->filterFirstN() to emulate last() with callback
|macro |addMethod, addMethodForAllInstances & addStaticMethod
|make |makeNew
|map |map
|mapInto |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|mapSpread |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|mapToDictionary |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|mapToGroups |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|mapWithKeys |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|max |NumericsCollection::max, `$coll->getAsNewType(\VersatileCollections\NumericsCollection::class)->max();` where `$coll` is an instance of CollectionInterface containing integers and / or floats.
|median |NumericsCollection::median, `$coll->getAsNewType(\VersatileCollections\NumericsCollection::class)->median();` where `$coll` is an instance of CollectionInterface containing integers and / or floats.
|merge |mergeWith & mergeMeWith
|min |NumericsCollection::min, `$coll->getAsNewType(\VersatileCollections\NumericsCollection::class)->min();` where `$coll` is an instance of CollectionInterface containing integers and / or floats.
|mode |NumericsCollection::mode, `$coll->getAsNewType(\VersatileCollections\NumericsCollection::class)->mode();` where `$coll` is an instance of CollectionInterface containing integers and / or floats.
|nth |everyNth
|only |getAllWhereKeysIn
|pad |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|partition |Not implemented, will be implemented in a later version
|pipe |pipeAndReturnCallbackResult & pipeAndReturnSelf
|pluck |column
|pop |getAndRemoveLastItem
|prepend |prependItem & prependCollection
|pull |pull
|push |push & appendItem
|put |put
|random |randomItem, randomItems, randomKey & randomKeys
|reduce |reduce & reduceWithKeyAccess
|reject |Not Implemented, may implement if there is enough demand or if a pull request is submitted, use filterAll instead
|reverse |reverse & reverseMe
|search |searchAllByVal, searchByCallback & searchByVal
|shift |getAndRemoveFirstItem
|shuffle |shuffle
|slice |slice
|some |containsItem, containsItems, containsKey, containsKeys & containsItemWithKey. All use strict comparison
|sort, sortBy, sortByDesc |sort, sortDesc, sortByMultipleFields, sortMe, sortMeDesc, sortMeByMultipleFields
|sortKeys, sortKeysDesc |sortByKey, sortDescByKey, sortMeByKey, sortMeDescByKey
|splice |splice
|split |split
|sum |NumericsCollection::sum, `$coll->getAsNewType(\VersatileCollections\NumericsCollection::class)->sum();` where `$coll` is an instance of CollectionInterface containing integers and / or floats.
|take |take
|tap |tap
|times |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|toArray |toArray. Just returns underlying array, no traversal of items to process them before returning.
|toJson |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|transform |transform
|union |unionWith & unionMeWith
|unique |ScalarsCollection::uniqueNonStrict
|uniqueStrict |unique
|unless |whenFalse
|unwrap |Same as toArray() on an instance
|values |getItems
|when |whenTrue
|where |Not implemented, will be implemented in a later version
|whereStrict |Not implemented, will be implemented in a later version
|whereIn |Not implemented, will be implemented in a later version
|whereInStrict |Not implemented, will be implemented in a later version
|whereInstanceOf |Not implemented, will be implemented in a later version
|whereNotIn |Not implemented, will be implemented in a later version
|whereNotInStrict |Not implemented, will be implemented in a later version
|wrap |Not Implemented, may implement if there is enough demand or if a pull request is submitted
|zip |Not Implemented, may implement if there is enough demand or if a pull request is submitted

0 comments on commit be01461

Please sign in to comment.