File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,13 @@ public function map(array $data): array
1717
1818 $ tiers = [];
1919 foreach ($ data as $ item ) {
20- $ tiers [] = $ mapper ->map ($ item );
20+ $ tier = $ mapper ->map ($ item );
21+
22+ if (!$ tier ) {
23+ continue ;
24+ }
25+
26+ $ tiers [] = $ tier ;
2127 }
2228
2329 return $ tiers ;
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ public static function list(array $params = []): array
109109 *
110110 * @throws MaintenanceModeException|GuzzleException|PiggyRequestException
111111 */
112- public static function findBy (string $ contactUuid , array $ params = []): Tier
112+ public static function findBy (string $ contactUuid , array $ params = []): ? Tier
113113 {
114114 $ response = ApiClient::get (self ::contactsResourceUri."/ $ contactUuid/tier " , $ params );
115115
Original file line number Diff line number Diff line change 66
77class TierMapper
88{
9- public static function map ($ data ): Tier
9+ public static function map ($ data ): ? Tier
1010 {
11+ if (!$ data ->name ) {
12+ return null ;
13+ }
14+
1115 return new Tier (
1216 $ data ->name ,
13- $ data ->position ,
17+ $ data ->position ?? 0 ,
1418 $ data ->uuid ?? null ,
1519 $ data ->description ?? null ,
1620 $ data ->media ? get_object_vars ($ data ->media ) : null
Original file line number Diff line number Diff line change @@ -8,7 +8,13 @@ public static function map($data): array
88 {
99 $ tiers = [];
1010 foreach ($ data as $ item ) {
11- $ tiers [] = TierMapper::map ($ item );
11+ $ tier = TierMapper::map ($ item );;
12+
13+ if (!$ tier ) {
14+ continue ;
15+ }
16+
17+ $ tiers [] = $ tier ;
1218 }
1319
1420 return $ tiers ;
You can’t perform that action at this time.
0 commit comments