exit;
}
$enrichmentField = '';
if (is_null($options['enrichment'])) {
    echo "parameter --enrichment not specified; function will now exit" . PHP_EOL;
    exit;
} else {
    $enrichmentField = $options['enrichment'];
}
$getType = 'getTitle' . ucfirst(strtolower($options['type']));
$addType = 'addTitle' . ucfirst(strtolower($options['type']));
if ($dryrun) {
    _log("TEST RUN: NO DATA WILL BE MODIFIED");
}
$docFinder = new Opus_DocumentFinder();
$docIds = $docFinder->setEnrichmentKeyExists($enrichmentField)->ids();
_log(count($docIds) . " documents found");
foreach ($docIds as $docId) {
    $doc = new Opus_Document($docId);
    if ($doc->getType() == $doctype || $doctype == '') {
        $enrichments = $doc->getEnrichment();
        foreach ($enrichments as $enrichment) {
            $enrichmentArray = $enrichment->toArray();
            if ($enrichmentArray['KeyName'] == $enrichmentField) {
                $titles = $doc->{$getType}();
                if (count($titles) > 0) {
                    _log('Title ' . ucfirst(strtolower($options['type'])) . ' already exists for Document #' . $docId . '. Skipping.. ');
                } else {
                    $title = $doc->{$addType}();
                    $title->setValue($enrichmentArray['Value']);
                    if (!$dryrun) {