private function buildGapImgCollection(array $possibleResponses, $matchMax)
 {
     $gapImageCollection = new GapImgCollection();
     foreach ($possibleResponses as $index => $possibleResponse) {
         $html = new SimpleHtmlDom();
         $html->load($possibleResponse);
         $img = $html->find('img');
         // Detect `img` and make sure it is an image
         if (count($img) === 1) {
             // TODO: Validation these attributes exists
             $src = $img[0]->src;
             $imagesize = getimagesize(CurlUtil::prepareUrlForCurl($src));
             $gapImageObject = new Object($src, $imagesize['mime']);
             $gapImageObject->setWidth($imagesize[0]);
             $gapImageObject->setHeight($imagesize[1]);
             // No `img` assuming its all text
         } elseif (count($img) === 0) {
             $gapImageObject = $this->convertTextToObjectWithBase64ImageString($possibleResponse);
         } else {
             throw new MappingException('Does not support mapping `possible_responses` as HTML, has to be either just a single `image` or `text`');
         }
         $gapImageCollection->attach(new GapImg(self::GAPIMG_IDENTIFIER_PREFIX . $index, $matchMax, $gapImageObject));
     }
     return $gapImageCollection;
 }
 public static function build($identifier, $bgObject, $gapImgs, $hotspots)
 {
     $gapImgCollection = new GapImgCollection();
     foreach ($gapImgs as $id => $data) {
         $obj = new Object($data, 'image/png');
         $gapImg = new GapImg($id, 1, $obj);
         $gapImgCollection->attach($gapImg);
     }
     $associableHotspotCollection = new AssociableHotspotCollection();
     foreach ($hotspots as $id => $data) {
         $coords = new QtiCoords(QtiShape::RECT, $data);
         $associableHotspot = new AssociableHotspot($id, 1, QtiShape::RECT, $coords);
         $associableHotspotCollection->attach($associableHotspot);
     }
     return new GraphicGapMatchInteraction($identifier, $bgObject, $gapImgCollection, $associableHotspotCollection);
 }