Example #1
0
 /**
  * @param $response
  * @return Image
  */
 public function populateResponse($response)
 {
     if (!$response) {
         return null;
     }
     $responseArrays = json_decode($response, 1);
     $this->checkError($responseArrays);
     $imageArrays = isset($responseArrays['images']) ? $responseArrays['images'] : [];
     $image = new Image();
     foreach ($imageArrays as $imageArray) {
         $image->setAttributes($imageArray);
         $transaction = new Transaction();
         $transaction->setAttributes(isset($imageArray['transaction']) ? $imageArray['transaction'] : []);
         if (isset($imageArray['candidates'])) {
             foreach ($imageArray['candidates'] as $candidateArray) {
                 $candidate = new Candidate();
                 $candidate->setAttributes($candidateArray);
                 $image->candidates[] = $candidate;
             }
         }
     }
     return $image;
 }
Example #2
0
 /**
  * @param $response
  * @return Image
  */
 public function populateResponse($response)
 {
     if (!$response) {
         return null;
     }
     $responseArrays = json_decode($response, 1);
     $this->checkError($responseArrays);
     $imageArrays = isset($responseArrays['images']) ? $responseArrays['images'] : [];
     $image = new Image();
     foreach ($imageArrays as $imageArray) {
         $image->setAttributes($imageArray);
         $transaction = new Transaction();
         $transaction->setAttributes(isset($imageArray['transaction']) ? $imageArray['transaction'] : []);
         $gender = null;
         if (isset($imageArray['attributes']['gender'])) {
             $gender = new Gender();
             $gender->setAttributes($imageArray['attributes']['gender']);
         }
         $image->attributes['gender'] = $gender;
         $image->transaction = $transaction;
     }
     return $image;
 }