public function getPackageVersion()
 {
     $result = parent::getPackageVersion();
     if ($result === null) {
         $result = $this->pdo->findVersionById($this->packageVersionId);
         $this->setPackageVersion($result);
     }
     return $result;
 }
 private function persistDependency(PackageLink $packageLink)
 {
     $data = array($packageLink->getVersion()->getId(), $packageLink->getPackageVersion()->getId());
     $sql = "INSERT INTO " . $this->getTablePrefix() . "dependency\n                (version_id, package_version_id)\n                VALUES\n                (?, ?)";
     $stmt = $this->pdo->prepare($sql);
     $stmt->execute($data);
 }
 private function parseProjectDependencies(Version $version, array $dependencies)
 {
     foreach ($dependencies as $dependency) {
         $packageVersion = $dependencyVersion = $this->findDependency($dependency->name, $dependency->version);
         if (!$packageVersion) {
             throw new \Exception('The dependency "' . $dependency->name . '" does not exist.');
         }
         $packageLink = new PackageLink();
         $packageLink->setVersion($version);
         $packageLink->setPackageVersion($packageVersion);
         $version->addDependency($packageLink);
     }
 }