protected function validatePackageRepositories($index, $repo)
    {
        if ('package' !== $repo['type']) {
            return;
        }

        if (!isset($repo['package'])) {
            throw new \UnexpectedValueException('Repository '.$index.' ('.json_encode($repo).') must have a package definition"');
        }

        foreach (array('name', 'type', 'version', 'dist') as $key) {
            if (!isset($repo['package'][$key])) {
                throw new \UnexpectedValueException('Repository '.$index.' ('.json_encode($repo).') must have the "'.$key.'" key  in the package definition"');
            }
        }
    }