| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Cortex\Contacts\Transformers\Adminarea; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Rinvex\Support\Traits\Escaper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Cortex\Contacts\Models\Contact; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use League\Fractal\TransformerAbstract; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | class ContactTransformer extends TransformerAbstract | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     use Escaper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 17 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 18 |  |  |     public function transform(Contact $contact): array | 
            
                                                        
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 20 |  |  |         $country = $contact->country_code ? country($contact->country_code) : null; | 
            
                                                        
            
                                    
            
            
                | 21 |  |  |         $language = $contact->language_code ? language($contact->language_code) : null; | 
            
                                                        
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 23 |  |  |         return $this->escape([ | 
            
                                                        
            
                                    
            
            
                | 24 |  |  |             'id' => (string) $contact->getRouteKey(), | 
            
                                                        
            
                                    
            
            
                | 25 |  |  |             'given_name' => (string) $contact->given_name, | 
            
                                                        
            
                                    
            
            
                | 26 |  |  |             'family_name' => (string) $contact->family_name, | 
            
                                                        
            
                                    
            
            
                | 27 |  |  |             'email' => (string) $contact->email, | 
            
                                                        
            
                                    
            
            
                | 28 |  |  |             'phone' => (string) $contact->phone, | 
            
                                                        
            
                                    
            
            
                | 29 |  |  |             'title' => (string) $contact->title, | 
            
                                                        
            
                                    
            
            
                | 30 |  |  |             'organization' => (string) $contact->organization, | 
            
                                                        
            
                                    
            
            
                | 31 |  |  |             'country_code' => (string) optional($country)->getName(), | 
            
                                                        
            
                                    
            
            
                | 32 |  |  |             'country_emoji' => (string) optional($country)->getEmoji(), | 
            
                                                        
            
                                    
            
            
                | 33 |  |  |             'language_code' => (string) optional($language)->getName(), | 
            
                                                        
            
                                    
            
            
                | 34 |  |  |             'source' => (string) $contact->source, | 
            
                                                        
            
                                    
            
            
                | 35 |  |  |             'method' => (bool) $contact->method, | 
            
                                                        
            
                                    
            
            
                | 36 |  |  |             'created_at' => (string) $contact->created_at, | 
            
                                                        
            
                                    
            
            
                | 37 |  |  |             'updated_at' => (string) $contact->updated_at, | 
            
                                                        
            
                                    
            
            
                | 38 |  |  |         ]); | 
            
                                                        
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 40 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 41 |  |  |  |