1- <?php namespace GetStream \ StreamLaravel ;
1+ <?php
22
3- use GetStream \StreamLaravel \EnrichedActivity ;
4- use GetStream \StreamLaravel \Exceptions \MissingDataException ;
3+ namespace GetStream \StreamLaravel ;
54
6- class Enrich {
5+ use Carbon \ Carbon ;
76
8- private $ fields = array ();
7+ class Enrich
8+ {
9+ private $ fields = [];
10+ private $ withTrashed ;
911
10- public function __construct ($ fields = array ( 'actor ' , 'object ' ) , $ withTrashed = true )
12+ public function __construct ($ fields = [ 'actor ' , 'object ' ] , $ withTrashed = true )
1113 {
1214 $ this ->fields = $ fields ;
1315 $ this ->withTrashed = $ withTrashed ;
1416 }
1517
16- public function fromDb ($ model , $ ids , $ with= array () )
18+ public function fromDb ($ model , $ ids , $ with = [] )
1719 {
18- $ results = array () ;
20+ $ results = [] ;
1921 $ pkName = (new $ model ())->getKeyName ();
2022 $ query = $ model ::with ($ with )->whereIn ($ pkName , $ ids );
2123 if (in_array ('Illuminate\Database\Eloquent\SoftDeletingTrait ' , class_uses (get_class ($ model ))) && $ this ->withTrashed ) // previous withTrash method deprecated in Laravel 4.2
@@ -29,7 +31,7 @@ public function fromDb($model, $ids, $with=array())
2931
3032 private function collectReferences ($ activities )
3133 {
32- $ model_references = array () ;
34+ $ model_references = [] ;
3335 foreach ($ activities as $ key => $ activity ) {
3436 foreach ($ activity as $ field =>$ value ) {
3537 if ($ value === null ) {
@@ -46,10 +48,10 @@ private function collectReferences($activities)
4648
4749 private function retrieveObjects ($ references )
4850 {
49- $ objects = array () ;
51+ $ objects = [] ;
5052 foreach ($ references as $ content_type => $ content_ids ) {
5153 $ content_type_model = new $ content_type ;
52- $ with = array () ;
54+ $ with = [] ;
5355 if (method_exists ($ content_type_model , 'activityLazyLoading ' )) {
5456 $ with = $ content_type_model ->activityLazyLoading ();
5557 }
@@ -61,10 +63,11 @@ private function retrieveObjects($references)
6163
6264 private function wrapActivities ($ activities )
6365 {
64- $ wrappedActivities = array () ;
65- foreach ($ activities as $ i => $ activity ) {
66+ $ wrappedActivities = [] ;
67+ foreach ($ activities as $ activity ) {
6668 $ wrappedActivities [] = new EnrichedActivity ($ activity );
6769 }
70+
6871 return $ wrappedActivities ;
6972 }
7073
@@ -114,17 +117,16 @@ public function enrichAggregatedActivities($aggregatedActivities)
114117 return $ aggregatedActivities ;
115118 }
116119
117- $ references = array () ;
120+ $ references = [] ;
118121 foreach ($ aggregatedActivities as $ aggregated ) {
119122 $ references = array_replace_recursive ($ references , $ this ->collectReferences ($ aggregated ['activities ' ]));
120123 }
121124
122125 $ objects = $ this ->retrieveObjects ($ references );
123126 foreach ($ aggregatedActivities as $ key => $ aggregated ) {
124- $ aggregatedActivities [$ key ]['updated_at ' ] = new \ Carbon \ Carbon ($ aggregatedActivities [$ key ]['updated_at ' ]);
127+ $ aggregatedActivities [$ key ]['updated_at ' ] = new Carbon ($ aggregatedActivities [$ key ]['updated_at ' ]);
125128 $ this ->injectObjects ($ aggregatedActivities [$ key ]['activities ' ], $ objects );
126129 }
127130 return $ aggregatedActivities ;
128131 }
129-
130132}
0 commit comments