/**
  * Save each property of json content
  * in corresponidng field of database
  *
  * @param  object $ExtensionData
  * @return boolean
  */
 public function dataFields($ExtensionData)
 {
     $saveDataFields = array();
     try {
         $ExtensionData->Url = $this->url;
         if ($this->latestReleasePackage->getPrettyName()) {
             list($vendorName, $extensionName) = explode("/", $this->latestReleasePackage->getPrettyName());
             $ExtensionData->Title = $this->latestReleasePackage->getPrettyName();
             $ExtensionData->VendorName = $vendorName;
             $ExtensionData->Name = $extensionName;
         } else {
             throw new InvalidArgumentException("We could not find Name field in composer.json at'" . $this->url . "' ");
         }
         if ($this->latestReleasePackage->getDescription()) {
             $ExtensionData->Description = $this->latestReleasePackage->getDescription();
         } else {
             throw new InvalidArgumentException("We could not find Description field in composer.json at'" . $this->url . "' ");
         }
         if ($this->latestReleasePackage->getPrettyVersion()) {
             $ExtensionData->Version = $this->latestReleasePackage->getPrettyVersion();
         }
         if ($this->latestReleasePackage->getType()) {
             $type = $this->latestReleasePackage->getType();
             if (preg_match("/\\bmodule\\b/i", $type)) {
                 $ExtensionData->Type = 'Module';
             } elseif (preg_match("/\\btheme\\b/i", $type)) {
                 $ExtensionData->Type = 'Theme';
             } elseif (preg_match("/\\bwidget\\b/i", $type)) {
                 $ExtensionData->Type = 'Widget';
             } else {
                 throw new InvalidArgumentException("We could not find 'Type' field in composer.json at'" . $this->url . "' ");
             }
         }
         if ($this->latestReleasePackage->getHomepage()) {
             $ExtensionData->Homepage = $this->latestReleasePackage->getHomepage();
         }
         if ($this->latestReleasePackage->getReleaseDate()) {
             $ExtensionData->ReleaseTime = $this->latestReleasePackage->getReleaseDate()->format('Y-m-d H:i:s');
         }
         if ($this->latestReleasePackage->getLicense()) {
             $licence = $this->latestReleasePackage->getLicense();
             if (array_key_exists('type', $licence)) {
                 $ExtensionData->LicenceType = $licence['type'];
             }
             if (array_key_exists('description', $licence)) {
                 $ExtensionData->LicenceDescription = $licence['description'];
             }
         }
         if ($this->latestReleasePackage->getSupport()) {
             $supportData = $this->latestReleasePackage->getSupport();
             if (array_key_exists('email', $supportData)) {
                 $ExtensionData->SupportEmail = $supportData['email'];
             }
             if (array_key_exists('issues', $supportData)) {
                 $ExtensionData->SupportIssues = $supportData['issues'];
             }
             if (array_key_exists('forum', $supportData)) {
                 $ExtensionData->SupportForum = $supportData['forum'];
             }
             if (array_key_exists('wiki', $supportData)) {
                 $ExtensionData->SupportWiki = $supportData['wiki'];
             }
             if (array_key_exists('irc', $supportData)) {
                 $ExtensionData->SupportIrc = $supportData['irc'];
             }
             if (array_key_exists('source', $supportData)) {
                 $ExtensionData->SupportSource = $supportData['source'];
             }
         }
         if ($this->latestReleasePackage->getTargetDir()) {
             $ExtensionData->TargetDir = $this->latestReleasePackage->getTargetDir();
         }
         if ($this->latestReleasePackage->getRequires()) {
             $requires = $this->latestReleasePackage->getRequires();
             $allRequirePackage = array();
             foreach ($requires as $requirePackage) {
                 $allRequirePackage[$requirePackage->getTarget()] = $requirePackage->getPrettyConstraint();
                 if ($requirePackage->getTarget() == 'silverstripe/framework') {
                     $ExtensionData->CompatibleSilverStripeVersion = $requirePackage->getPrettyConstraint();
                 }
             }
             $ExtensionData->Require = serialize($allRequirePackage);
         } else {
             throw new InvalidArgumentException("We could not find 'require' field in composer.json at'" . $this->url . "' ");
         }
         if ($this->latestReleasePackage->getDevRequires()) {
             $ExtensionData->RequireDev = serialize($this->latestReleasePackage->getDevRequires());
         }
         if ($this->latestReleasePackage->getConflicts()) {
             $ExtensionData->Conflict = serialize($this->latestReleasePackage->getConflicts());
         }
         if ($this->latestReleasePackage->getReplaces()) {
             $ExtensionData->Replace = serialize($this->latestReleasePackage->getReplaces());
         }
         if ($this->latestReleasePackage->getProvides()) {
             $ExtensionData->Provide = serialize($this->latestReleasePackage->getProvides());
         }
         if ($this->latestReleasePackage->getSuggests()) {
             $ExtensionData->Suggest = serialize($this->latestReleasePackage->getSuggests());
         }
         if ($this->latestReleasePackage->getExtra()) {
             $ExtensionData->Extra = serialize($this->latestReleasePackage->getExtra());
             $extra = $this->latestReleasePackage->getExtra();
             if (array_key_exists('snapshot', $extra)) {
                 $ExtensionData->ThumbnailID = ExtensionSnapshot::save_snapshot($extra['snapshot'], $this->latestReleasePackage->getPrettyName());
             }
         }
         if ($this->latestReleasePackage->getRepositories()) {
             $ExtensionData->Repositories = serialize($this->latestReleasePackage->getRepositories());
         }
         if ($this->latestReleasePackage->getIncludePaths()) {
             $ExtensionData->IncludePath = serialize($this->latestReleasePackage->getIncludePaths());
         }
         if ($this->latestReleasePackage->getAuthors()) {
             ExtensionAuthorController::store_authors_info($this->latestReleasePackage->getAuthors(), $ExtensionData->ID);
         } else {
             throw new InvalidArgumentException("We could not find Author Info field in composer.json at'" . $this->url . "' ");
         }
         if ($this->latestReleasePackage->getKeywords()) {
             ExtensionKeywords::save_keywords($this->latestReleasePackage->getKeywords(), $ExtensionData->ID);
         } else {
             throw new InvalidArgumentException("We could not find Keywords field in composer.json at'" . $this->url . "' ");
         }
     } catch (Exception $e) {
         $saveDataFields['ErrorMsg'] = $e->getMessage();
         return $saveDataFields;
     }
     $ExtensionData->write();
     $saveDataFields['ExtensionID'] = $ExtensionData->ID;
     return $saveDataFields;
 }
 /**
  * @expectedException InvalidArgumentException
  */
 function testSaveSnapshotException()
 {
     $obj = $this->objFromFixture('ExtensionData', 'testmodule');
     $fakeUrl = 'http://openbees.org/images/FakeImage.jpg';
     ExtensionSnapshot::save_snapshot($fakeUrl, $obj->Name);
 }