@@ -127,24 +127,24 @@ public function nestPostsWithParent(): Collection
127127 public function reOrderNestedPosts (
128128 Collection $ nestedPosts ,
129129 string $ orderByField ,
130- bool $ orderByDesc ,
130+ bool $ isOrderByDesc ,
131131 ): Collection {
132132 $ sortBySortingKey = static fn (Collection $ posts ): Collection => $ posts
133- ->sortBy (fn (SortablePost $ post ) => $ post ->getSortingKey (), descending: $ orderByDesc )
133+ ->sortBy (fn (SortablePost $ post ) => $ post ->getSortingKey (), descending: $ isOrderByDesc )
134134 ->values (); // reset keys
135135 $ getOrderByProp = 'get ' . ucfirst ($ orderByField );
136136 return $ sortBySortingKey ($ nestedPosts ->map (
137- function (Thread $ thread ) use ($ getOrderByProp , $ orderByDesc , $ sortBySortingKey ): Thread {
137+ function (Thread $ thread ) use ($ getOrderByProp , $ isOrderByDesc , $ sortBySortingKey ): Thread {
138138 $ thread ->setReplies ($ sortBySortingKey ($ thread ->getReplies ()->map (
139- function (Reply $ reply ) use ($ getOrderByProp , $ orderByDesc ): Reply {
139+ function (Reply $ reply ) use ($ getOrderByProp , $ isOrderByDesc ): Reply {
140140 $ reply ->setSubReplies ($ reply ->getSubReplies ()->sortBy (
141141 fn (SubReply $ subReplies ) => $ subReplies ->{$ getOrderByProp }(),
142- descending: $ orderByDesc ,
142+ descending: $ isOrderByDesc ,
143143 )->values ()); // reset keys
144- return $ this ->setSortingKeyForSortablePost ($ reply , $ reply ->getSubReplies (), $ getOrderByProp , $ orderByDesc );
144+ return $ this ->setSortingKeyForSortablePost ($ reply , $ reply ->getSubReplies (), $ getOrderByProp , $ isOrderByDesc );
145145 },
146146 )));
147- $ this ->setSortingKeyForSortablePost ($ thread , $ thread ->getReplies (), $ getOrderByProp , $ orderByDesc );
147+ $ this ->setSortingKeyForSortablePost ($ thread , $ thread ->getReplies (), $ getOrderByProp , $ isOrderByDesc );
148148 return $ thread ;
149149 },
150150 ));
@@ -160,7 +160,7 @@ private function setSortingKeyForSortablePost(
160160 SortablePost $ currentPost ,
161161 Collection $ subPosts ,
162162 string $ getOrderByProp ,
163- bool $ orderByDesc ,
163+ bool $ isOrderByDesc ,
164164 ): SortablePost {
165165 // use the topmost value between sorting key or value of orderBy field within its sub-posts
166166 /* @var ?(T is Thread ? Reply : (T is Reply ? SubReply : never)) $firstSubPost */
@@ -185,7 +185,7 @@ private function setSortingKeyForSortablePost(
185185
186186 // Collection->filter() will remove falsy values like null
187187 $ currentAndSubPostSortingKeys = $ currentAndSubPostSortingKeys ->filter ()->sort ();
188- $ currentPost ->setSortingKey ($ orderByDesc
188+ $ currentPost ->setSortingKey ($ isOrderByDesc
189189 ? $ currentAndSubPostSortingKeys ->last ()
190190 : $ currentAndSubPostSortingKeys ->first ());
191191
0 commit comments