/** * @param String $string * @param $behavior */ private function registerString($string, $behavior) { $existingDoc = $this->findDocument($string->hash()); $doc = empty($existingDoc) ? $string->asDocument() : self::mergeStrings($existingDoc, $string->asDocument(), $behavior); if (isset($doc['_id'])) { $this->db->putDocument($doc, $doc['_id']); } else { $this->db->postDocument($doc); } }