| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace SquareetLabs\LaravelOpenVidu\Builders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use SquareetLabs\LaravelOpenVidu\Enums\MediaMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use SquareetLabs\LaravelOpenVidu\Enums\OutputMode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use SquareetLabs\LaravelOpenVidu\Enums\RecordingLayout; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SquareetLabs\LaravelOpenVidu\Exceptions\OpenViduInvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SquareetLabs\LaravelOpenVidu\Recording; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SquareetLabs\LaravelOpenVidu\RecordingProperties; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * Class RecordingBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @package SquareetLabs\LaravelOpenVidu\Builders | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class RecordingBuilder implements BuilderInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * @param  array  $properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @return Recording|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * @throws OpenViduInvalidArgumentException | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     public static function build(array $properties) | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         if (array_key_exists('sessionId', $properties)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |             return new Recording( | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |                 $properties['id'], | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |                 $properties['sessionId'], | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |                 $properties['createdAt'], | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |                 $properties['size'], | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |                 $properties['duration'], | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |                 $properties['url'], | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |                 new RecordingProperties( | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |                     $properties['sessionId'], | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |                     array_key_exists('name', $properties) ? $properties['name'] : RecordingLayout::BEST_FIT, | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |                     array_key_exists('outputMode', $properties) ? $properties['outputMode'] : OutputMode::COMPOSED, | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |                     array_key_exists('recordingLayout', $properties) ? $properties['recordingLayout'] : RecordingLayout::BEST_FIT, | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |                     array_key_exists('resolution', $properties) ? $properties['resolution'] : null, | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |                     array_key_exists('hasAudio', $properties) ? $properties['hasAudio'] : true, | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |                     array_key_exists('hasVideo', $properties) ? $properties['hasVideo'] : true, | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |                     array_key_exists('customLayout', $properties) ? $properties['customLayout'] : MediaMode::ROUTED | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |                 )); | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |         throw new OpenViduInvalidArgumentException('RecordingBuilder::build spects an array with sessionId key.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 48 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |  |