Repository: corona-warn-app/cwa-app-android
File: Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/vaccination/core/repository/VaccinationCertificateRepository.kt (Kotlin)

Code before:
            Timber.tag(TAG).d("recycleCertificate %s %s", value, it.containerId)
        }
    }

    private fun VaccinationCertificateContainer.markAsSeenByUser(): VaccinationCertificateContainer {
        return copy(data = data.copy(certificateSeenByUser = true)).also {
            Timber.tag(TAG).d("markAsSeenByUser %s", it.containerId)
        }
    }

    private fun VaccinationCertificateQRCode.createContainer(
        nowUtc: Instant = timeStamper.nowUTC
    ): VaccinationCertificateContainer =
        toVaccinationContainer(
            scannedAt = nowUtc,
            qrCodeExtractor = qrCodeExtractor,
            certificateSeenByUser = false,
        )

    private fun VaccinationCertificateContainer.toVaccinationCertificateOrNull(
        valueSet: VaccinationValueSets?,
        certificateState: CwaCovidCertificate.State
    ): VaccinationCertificate? {
        try {
            return toVaccinationCertificate(valueSet, certificateState).also {
                // read value from dcc data to throws an exception early if the DccQrCodeExtractor is not able to parse
                // the certificate
                it.personIdentifier
            }
        } catch (e: Exception) {
            Timber.e(e, "Creating VaccinationCertificate failed")
        }
        return null
    }

    private suspend fun VaccinationCertificateContainer.toVaccinationCertificateWrapper(
        valueSets: VaccinationValueSets,
        dccValidityMeasures: DccValidityMeasures
    ): VaccinationCertificateWrapper? {
        try {
            val state = dccState(
                dccData = certificateData,
                qrCodeHash = qrCodeHash,
                dccValidityMeasures = dccValidityMeasures
            )

            return VaccinationCertificateWrapper(
                valueSets = valueSets,
                container = this,
                certificateState = state
            )

Review comment (refactor):
```suggestion
                // read value from dcc data to throw an exception early if the DccQrCodeExtractor is not able to parse
```

Code after:
            Timber.tag(TAG).d("recycleCertificate %s %s", value, it.containerId)
        }
    }

    private fun VaccinationCertificateContainer.markAsSeenByUser(): VaccinationCertificateContainer {
        return copy(data = data.copy(certificateSeenByUser = true)).also {
            Timber.tag(TAG).d("markAsSeenByUser %s", it.containerId)
        }
    }

    private fun VaccinationCertificateQRCode.createContainer(
        nowUtc: Instant = timeStamper.nowUTC
    ): VaccinationCertificateContainer =
        toVaccinationContainer(
            scannedAt = nowUtc,
            qrCodeExtractor = qrCodeExtractor,
            certificateSeenByUser = false,
        )

    private fun VaccinationCertificateContainer.toVaccinationCertificateOrNull(
        valueSet: VaccinationValueSets?,
        certificateState: CwaCovidCertificate.State
    ): VaccinationCertificate? {
        try {
            return toVaccinationCertificate(valueSet, certificateState).also {
                // read value from dcc data to throw an exception early if the DccQrCodeExtractor is not able to parse
                // the certificate
                it.personIdentifier
            }
        } catch (e: Exception) {
            Timber.e(e, "Creating VaccinationCertificate failed")
        }
        return null
    }

    private suspend fun VaccinationCertificateContainer.toVaccinationCertificateWrapper(
        valueSets: VaccinationValueSets,
        dccValidityMeasures: DccValidityMeasures
    ): VaccinationCertificateWrapper? {
        try {
            val state = dccState(
                dccData = certificateData,
                qrCodeHash = qrCodeHash,
                dccValidityMeasures = dccValidityMeasures
            )

            return VaccinationCertificateWrapper(
                valueSets = valueSets,
                container = this,
                certificateState = state
            )