Ejemplo n.º 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);
         $faces = [];
         foreach ($imageArray['faces'] as $faceArray) {
             $face = new Face();
             $face->setAttributes($faceArray);
             if (isset($faceArray['attributes']['gender'])) {
                 $gender = new Gender();
                 $gender->setAttributes($faceArray['attributes']['gender']);
                 $face->attributes['gender'] = $gender;
             }
             $faces[] = $face;
         }
         $image->faces = $faces;
     }
     return $image;
 }
Ejemplo n.º 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'] : []);
         if (isset($imageArray['candidates'])) {
             foreach ($imageArray['candidates'] as $candidateArray) {
                 $candidate = new Candidate();
                 $candidate->setAttributes($candidateArray);
                 $image->candidates[] = $candidate;
             }
         }
     }
     return $image;
 }
Ejemplo n.º 3
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;
 }