| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace mikemix\Wiziq\API; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use mikemix\Wiziq\API\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use mikemix\Wiziq\Common\Api\ClassroomApiInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use mikemix\Wiziq\Entity\Attendees; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use mikemix\Wiziq\Entity\Classroom; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use mikemix\Wiziq\Entity\PermaClassroom; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class ClassroomApi implements ClassroomApiInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     /** @var Gateway */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     protected $gateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 | 7 |  |     public function __construct(Gateway $requester) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 | 7 |  |         $this->gateway = $requester; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 | 7 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 1 |  |     public function create(Classroom $classroom) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 1 |  |         $response = $this->gateway->sendRequest(new Request\Create($classroom)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 1 |  |             ->create[0]->class_details[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 1 |  |             'class_id'        => (int)$response->class_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 1 |  |             'recording_url'   => (string)$response->recording_url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 1 |  |             'presenter_email' => (string)$response->presenter_list[0]->presenter[0]->presenter_email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 1 |  |             'presenter_url'   => (string)$response->presenter_list[0]->presenter[0]->presenter_url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 1 |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 1 |  |     public function modify($classroomId, Classroom $classroom) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 1 |  |         $response = (boolean)$this->gateway->sendRequest(new Request\Modify($classroomId, $classroom))->modify["status"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 1 |  |         return $response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     public function download($classroomId, $recordingFormat = 'zip') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $response = $this->gateway->sendRequest(new Request\Download($classroomId, $recordingFormat))->download_recording; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         return $response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 58 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 59 | 1 |  |     public function cancel($classroomId) | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 | 1 |  |         $response = (boolean)$this->gateway->sendRequest(new Request\Cancel($classroomId))->cancel['status']; | 
            
                                                                        
                            
            
                                    
            
            
                | 62 | 1 |  |         return $response; | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 1 |  |     public function getAttendanceReport($classroomId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 1 |  |         $attendance = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 | 1 |  |         $response = $this->gateway->sendRequest(new Request\AttendanceReport($classroomId))->get_attendance_report; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 1 |  |         foreach($response->attendee_list[0] as $attendee) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             $data = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 1 |  |                     'entry_time'       => (string)$attendee->entry_time, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 | 1 |  |                     'exit_time'        => (string)$attendee->exit_time, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |                     'attended_minutes' => (string)$attendee->attended_minutes, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 1 |  |                     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |             if(isset($attendee['presenter']) and $attendee['presenter']==true) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 1 |  |                 $data['presenter_id'] = (int)$attendee->presenter_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 | 1 |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 1 |  |                 $data['attendee_id'] = (int)$attendee->attendee_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 | 1 |  |             $attendance[] = $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |         return $attendance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 | 1 |  |     public function createPermaClas(PermaClassroom $classroom) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 1 |  |         $response = $this->gateway->sendRequest(new Request\CreatePermaClass($classroom)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 1 |  |         $details  = $response->create_perma_class[0]->perma_class_details[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 1 |  |             'class_id'        => (int)$details->class_master_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 1 |  |             'attendee_url'    => (string)$details->common_perma_attendee_url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 1 |  |             'presenter_email' => (string)$details->presenter[0]->presenter_email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 | 1 |  |             'presenter_url'   => (string)$details->presenter[0]->presenter_url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 | 1 |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 | 1 |  |     public function addAttendeesToClass($classroomId, Attendees $attendees) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 | 1 |  |         $response = $this->gateway->sendRequest(new Request\AddAttendees($classroomId, $attendees)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 1 |  |         $result   = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 | 1 |  |         foreach ($response->add_attendees[0]->attendee_list[0] as $attendee) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 | 1 |  |             $result[] = ['id' => (int)$attendee->attendee_id, 'url' => (string)$attendee->attendee_url]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 1 |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * @codeCoverageIgnore | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      * @param \SimpleXMLElement $response | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     protected function getPresentersFromResponse(\SimpleXMLElement $response) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $presenters = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         foreach ($response->presenter_list[0] as $presenter) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             $presenters[] = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 'email' => (string)$presenter->presenter_email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 'url'   => (string)$presenter->presenter_url, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         return $presenters; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 140 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 141 |  |  |  | 
            
                        
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.